flashvars 未在 Adob​​e Flash Builder 的 Flex 4.5 应用程序中加载

发布于 2024-12-13 04:14:50 字数 2466 浏览 0 评论 0原文

我正在按照这个adobe flashvars示例来尝试加载flashvars在我的 Flex 4.5 应用程序中。但是,该代码不起作用。我真的不明白我做错了什么,或者与示例不同。这是我的 index.template.html 代码(在 html-template 文件夹中),它使用 swfobject 加载应用程序:

        function embedPlayer() {
            var flashvars = {};
            flashvars.userLoggedIn = true;
            flashvars.test = "hello";
            embedSWF(SWF_FILE, SWF_ID, SWF_WIDTH, SWF_HEIGHT, "9.0", "playerProductInstall.swf", flashvars);
        }

这是我的 Flex 应用程序的简化代码:

    <?xml version="1.0" encoding="utf-8"?>
<s:Application 
    xmlns:d="http://ns.adobe.com/fxg/2008/dt" 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    xmlns:c="components.*" 
    initialize="mainInit()" 
    creationComplete="doCreationComplete()"
    applicationComplete="_initializer.applicationComplete()"
    xmlns:application="components.application.*" 
    xmlns:gui="com.gui.*" xmlns:main="com.gui.components.main.*" xmlns:photoTray="com.gui.components.main.photoTray.*">

    <fx:Style source="/assets/all.css" />

    <fx:Script>
        <![CDATA[
            import com.gui.components.main.Initializer;
            import com.gui.components.main.LayoutsController;
            import mx.core.FlexGlobals;         

            private var _initializer:Initializer;
            private var _layoutsController:LayoutsController;
            public var userLoggedIn:Boolean;                                                                 

            private function mainInit():void {
                _initializer = new Initializer(this);
            }

            private function doCreationComplete():void {
                _initializer.init();
                var params:Object = FlexGlobals.topLevelApplication.parameters;
                //userLoggedIn = params.userLoggedIn;
                _layoutsController = new LayoutsController(this);
            }   

        ]]>
    </fx:Script>

</s:Application>

我调用 FlexGlobals.topLevelApplication.parameters (创建完成后)来尝试和访问 flashvars,这就是 adobe 所说的在 flex 4.5 中执行此操作的方法。根据我的研究,使用 Application.application.parameters 和 root.loaderInfo.parameters 均已弃用。

有人看到我做错了什么吗?我的应用程序在 flash 构建器中运行良好,除了在创建完成时加载 flashvars 之外。

谢谢

I am following this adobe flashvars example to try and get flashvars loading in my flex 4.5 application. However, the code is not working. I don't really understand what I'm doing wrong, or differently from the example. here is my index.template.html code (in the html-template folder) which uses swfobject to load the application:

        function embedPlayer() {
            var flashvars = {};
            flashvars.userLoggedIn = true;
            flashvars.test = "hello";
            embedSWF(SWF_FILE, SWF_ID, SWF_WIDTH, SWF_HEIGHT, "9.0", "playerProductInstall.swf", flashvars);
        }

And here is the simplified code from my flex application:

    <?xml version="1.0" encoding="utf-8"?>
<s:Application 
    xmlns:d="http://ns.adobe.com/fxg/2008/dt" 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    xmlns:c="components.*" 
    initialize="mainInit()" 
    creationComplete="doCreationComplete()"
    applicationComplete="_initializer.applicationComplete()"
    xmlns:application="components.application.*" 
    xmlns:gui="com.gui.*" xmlns:main="com.gui.components.main.*" xmlns:photoTray="com.gui.components.main.photoTray.*">

    <fx:Style source="/assets/all.css" />

    <fx:Script>
        <![CDATA[
            import com.gui.components.main.Initializer;
            import com.gui.components.main.LayoutsController;
            import mx.core.FlexGlobals;         

            private var _initializer:Initializer;
            private var _layoutsController:LayoutsController;
            public var userLoggedIn:Boolean;                                                                 

            private function mainInit():void {
                _initializer = new Initializer(this);
            }

            private function doCreationComplete():void {
                _initializer.init();
                var params:Object = FlexGlobals.topLevelApplication.parameters;
                //userLoggedIn = params.userLoggedIn;
                _layoutsController = new LayoutsController(this);
            }   

        ]]>
    </fx:Script>

</s:Application>

I call FlexGlobals.topLevelApplication.parameters (after creationComplete) to try and access flashvars, which is what adobe says is the way to do it in flex 4.5. From my research using Application.application.parameters and root.loaderInfo.parameters are both deprecated.

Does anyone see what I am doing wrong? My application works fine in flash builder except for flashvars loading on creationComplete.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以可爱出名 2024-12-20 04:14:50

这就是我在 Flex 3 中执行此操作的方法,不确定它是否适用于 Flex 4.5

Application.application.parameters.userLoggedIn

同样在这一行中

//userLoggedIn = params.userLoggedIn;

任何 flash var 的值都是您尝试分配布尔值的字符串。
所以就这样做吧。

//userLoggedIn = Boolean(params.userLoggedIn);

This is how I do it in flex 3 not sure it applies to flex 4.5

Application.application.parameters.userLoggedIn

Also on this line

//userLoggedIn = params.userLoggedIn;

The value of any flash var is a string which you are trying to assign a Boolean.
So do this.

//userLoggedIn = Boolean(params.userLoggedIn);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文