0

我正在尝试通过 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);
}
4

1 回答 1

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);
}
于 2013-01-25T09:26:03.103 回答