Flex 绑定变量无效

Flex bind variable has no effect

无论我做什么,我都无法在初始化期间对 Flex MXML 元素产生任何影响。 我想根据 flashVar 是否为真显示不同的徽标。

出于某种原因,flashvar 对元素的显示方式没有影响。

我错过了什么吗?

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark"
     xmlns:components="ru.kutu.grindplayer.views.components.*"
     mouseEnabled="false"
     implements="ru.kutu.grind.views.api.IMainView"
     preinitialize="preinitialize(event)"
     >

<s:states>
    <s:State name="initializing" />
    <s:State name="ready" />
    <s:State name="error" />
</s:states>

<s:BorderContainer 
    id="logoContainer"
    left="0" right="0"
    top="0" bottom="0"
    mouseEnabled="false"
    includeIn="initializing"
    backgroundColor="0x070707"
    borderVisible = "false"
>
    <s:Image  
        id="logoPaid"
        verticalCenter="0"
        horizontalCenter="0"
        source="@Embed('/../assets/skin/dark.png')"
        visible="{is_paid}"
    />
    <s:Image  
        id="logoFree"
        verticalCenter="0"
        horizontalCenter="0"
        source="@Embed('/../assets/skin/dark_free.png')"
        visible="{!is_paid}"
    />
</s:BorderContainer> 

<components:PlayerView
    id="playerView"
    left="0" right="0"
    top="0" bottom="0"
    visible="false"
    visible.ready="true"
    />

<s:Label
    id="errorDisplay"
    width="80%"
    mouseEnabled="false"
    verticalCenter="0"
    horizontalCenter="0"
    includeIn="error"
    itemCreationPolicy="immediate"
    />


<s:transitions>
    <s:Transition
        fromState="*" toState="*"
        autoReverse="true"
        interruptionBehavior="stop"
        >
        <s:Fade 
            target="{this}"
            duration="300"
          />
    </s:Transition>
</s:transitions>


<fx:Script>
    <![CDATA[
        import mx.core.FlexGlobals;
        import mx.events.FlexEvent;

        [Bindable]
        private var is_paid:Boolean; 

        public function set errorText(value:String):void {
            errorDisplay.text = value;
        }

        public function initializing(is_paid:Boolean):void {
            currentState = "initializing";
        }

        public function ready():void {
            currentState = "ready";
        }

        public function error():void {
            currentState = "error";
        }

        private function preinitialize(event:FlexEvent):void {
            is_paid = FlexGlobals.topLevelApplication.parameters.is_paid;
        }
    ]]>
</fx:Script>

我认为您将字符串解析为布尔值。因为参数名称和值是字符串,试试这个:

is_paid = FlexGlobals.topLevelApplication.parameters.is_paid == 'true';