views:

46

answers:

1

I read though this answer for as3, which is not working for as2.

What's the most compatible way to handle parameters in flash?

A: 

There a lot of possibilities to achieve it, the one I prefer is using FlashVars with SWFObject:

<div id="flashcontent">
Your message if JavaScript is not enabled.
</div>
<script type="text/javascript">
var so = new SWFObject("yourmovie.swf", "yourmovie", "950", "30", "9");
so.addVariable("color", "red");
so.addVariable("speed", "3");
so.write("flashcontent");
</script>

Once your movie is loaded, the "color" and "speed" variables will be available from _root:

trace(_root.color); 

To ensure FlashVars are loaded correctly, I use an onEnterFrame function that loops until the external variables are loaded (!= undefined).

jdecuyper
`<embed>` is not supported by all browsers,right?
wamp
No, it's not but it was merely illustrative, I updated the code with a more cross-browser solution.
jdecuyper