简体   繁体   中英

Flex bind variable has no effect

No matter what I do, I cannot have any effect on Flex MXML elements during initialization. I want to display a different logo depending on whether a flashVar is true or not.

For some reason the flashvar has no effect on how the elements appear.

Am I missing anything ?

<?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>

I think you parse String into Boolean. Cause params names and values are String, try this instead:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM