我正在使用 FlashVars 在swf中传递参数但它无效。
这是html代码:
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="tpc">
<param name="movie" value="tpc.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name=FlashVars value="myVariable=Hello%20World&mySecondVariable=Goodbye">
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="tpc.swf" width="100%" height="100%">
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
**<param name=FlashVars value="myVariable=Hello%20World&mySecondVariable=Goodbye">**
<!--<![endif]-->
<!--[if gte IE 6]>-->
<p>
Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0.0 or greater is not installed.
</p>
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</noscript>
这是.mxml文件代码:
var keyStr:String;
var valueStr:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var length:int = 0;
for (keyStr in paramObj) {
length++;
}
if (length == 0) {
ta.appendText("Length is zero so below is the dummy data:\n");
paramObj = {test:"Test", test2:"Test2"};
}
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
ta.appendText("\t" + keyStr + ":\t" + valueStr + "\n");
}
答案 0 :(得分:3)
首先,不要使用该HTML。使用swfobject将Flash swf嵌入到html中。 Adobe更容易做到并支持。
其次,您没有正确访问变量,并且可能过早地尝试访问变量。在尝试访问应用程序之前,您需要等待应用程序的creationComplete事件。有一个真正的好tutorial on everything I just said on Adobe Help。
答案 1 :(得分:0)
在<object>
内尝试添加<embed>
,如下所示:
<embed src="file.swf?myVariable=Hello%20World&mySecondVariable=Goodbye" width="" height="" />