[英]How to pass parameters to actionscript 2 in flash?
I read though this answer for as3
, which is not working for as2
. 我虽然读过as3
答案 ,但不适用于as2
。
What's the most compatible way to handle parameters in flash? 在Flash中处理参数最兼容的方法是什么?
There a lot of possibilities to achieve it, the one I prefer is using FlashVars with SWFObject : 有很多方法可以实现它,我更喜欢将FlashVars与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: 加载影片后,_root将提供“ color”和“ speed”变量:
trace(_root.color);
To ensure FlashVars are loaded correctly, I use an onEnterFrame function that loops until the external variables are loaded (!= undefined). 为了确保FlashVars正确加载,我使用了一个onEnterFrame函数,该函数会循环运行直到加载外部变量为止(!= undefined)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.