Sending javascript variables to flash?

Chris G

New member
I am looking to send a variable which contains an image url, into flash. Can someone either tell me, or send me a tutorial on how to do this please, thanks :)

oh and its gotta be ActionScript 2.0
 
When embedding your flash file using the <object> tag add another param called "FlashVars". It should look like this:

<param name="FlashVars" value="variable=5">

And in your <embed> tag add another parameter called "FlashVars" with the same information like this:

<embed FlashVars="variable=5" id="...></embed>

Now these values are available to you in Flash. You can call them just like any other value:

if(_root.variable == 5) {
//do something here
}

FlashVars must be assigned in both the <object> and <embed> tags in order to work on all browsers.

You can add multiple variables by separating them with & like this:

FlashVars="variable1=1&valiable2=2"

Don't quote strings or you'll accidentally terminate the parameter.
 
Back
Top