将 flashvar 传递到 flex 4
我试图让用户通过在调用 JavaScript 的 flashvars 变量中设置颜色来设置我的 Flex 4 应用程序的背景颜色。
但是,我似乎根本无法访问 flashvars,我(从跟踪)得到的最佳结果是未定义。
javascript 看起来像:
<script type="text/javascript">
var flashvars = {};
flashvars.firstname = "bob";
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "#FF0000"
};
var attributes = {
id:"OvaWidget"
};
swfobject.embedSWF("myApp.swf", "altContent", "100%", "100%", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
</script>
我的 mxml 是
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
[Bindable]
public var firstname:String;
protected function init():void
{
trace(FlexGlobals.topLevelApplication.parameters[firstname]);
}
]]>
</fx:Script>
<s:Label text="Name: "/>
<s:Label text="{firstname}" fontWeight="bold"/>
有什么想法吗?感谢所有帮助!
I am trying to let the user set the background color of my flex 4 app by setting the colour in the flashvars variable of the calling javascript.
However, I don't seem to be able to access the flashvars at all, the best result I can get (from trace) is undefined.
The javascript looks like:
<script type="text/javascript">
var flashvars = {};
flashvars.firstname = "bob";
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "#FF0000"
};
var attributes = {
id:"OvaWidget"
};
swfobject.embedSWF("myApp.swf", "altContent", "100%", "100%", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
</script>
And my mxml is
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
[Bindable]
public var firstname:String;
protected function init():void
{
trace(FlexGlobals.topLevelApplication.parameters[firstname]);
}
]]>
</fx:Script>
<s:Label text="Name: "/>
<s:Label text="{firstname}" fontWeight="bold"/>
Any ideas? All help appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您创建一个 flashVars 对象。
所以你需要将代码更改为:
You create an flashVars-object.
So you need to change your code to this: