我试图通过swfobject oject,通过javascript:
初始化一些flash变量var flashvars = {param: "one"};
var params = {};
var attributes = {};
attributes.id = "as3_js";
swfobject.embedSWF("test.swf", "alt", "450", "450", "9.0.0", false, flashvars, params, attributes);
我正在尝试使用Flex 4,但my_param永远不会从flashvars中获取价值并且从未发出警告:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initApp()">
public function initApp():void
{
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var icon_url:String;
icon_url = paramObj['param'];
my_param = icon_url;
Alert.show(my_param);
}
答案 0 :(得分:1)
你可以找到解决方案@skabir提到的链接。这里只提一下错误所在你可以使用FlexGlobals.topLevelApplication而不是LoaderInfo(this.root.loaderInfo)。
public function initApp():void
{
var paramObj:Object = Application(FlexGlobals.topLevelApplication).parameters;
var my_param:String = paramObj['param'];
Alert.show(my_param);
}