disabled-controlapache-royale

Apache Royale : equivalent of enabled property on j:Button


I have issue on using "enabled" with j:Button.

I know that I must add functionality with this bead :

<j:Button id="bp_next" text="Next" >
    <j:beads>
        <j:Disabled/>
    </j:beads>
</j:Button>

But now I have the button showing disabled state.

How to change enabled/disabled with AS3 code as there is no enabled property on j:Button ?

Regards


Solution

  • There are a couple of ways this can be achieved.

    Access the bead dynamically on the button

    (bp_next.getBeadByType(Disabled) as Disabled).disabled = true|false;
    

    or,

    Disabled(bp_next.getBeadByType(Disabled)).disabled = true|false;
    

    Bind a variable to the bead's disabled field

    <j:Button localId="bp_next" text="Next" >
        <j:beads>
            <j:Disabled disabled="{someVariable}"/>
        </j:beads>
    </j:Button>
    

    In AS3:

    someVariable = true|false;
    

    Add an id to the disabled bead

    <j:Button localId="bp_next" text="Next" >
        <j:beads>
            <j:Disabled localId="bp_next_disabled"/>
        </j:beads>
    </j:Button>
    

    In AS3:

    bp_next_disabled.disabled = true|false;