tags:

views:

29

answers:

2

Hello,I've done a data-binding following a tutorial on the web:

<mx:Script><![CDATA[
        public static const selectedChild:Boolean = true;
        ]]></mx:Script>
<mx:Button label="{resourceManager.getString('resources', 'button.startLab')}" 
               id="nextStepButton" enabled="{selectedChild}" />

My question is how we can accsess this bindable variable from another mxml file?

Thanks.

A: 

yes you can

ClassName.variable_name will give you the value

Avi Tzurel
+1  A: 

As already stated, you can access selectedChild from another class using ClassName.selectedChild, where ClassName is the name of your mxml file.

Please note couple of things though:

  • selectedChild is not declared as bindable. You should use the [Bindable] metadata tag to make a variable declared in actionscript to be bindable.
  • selectedChild is declared as const, meaning its value cannot change in between. Thus, you need not use data binding on that field - just assign the value to the enabled field of the button once it is created.
  • It is declared as static - which means there is only one instance of it for the whole class. If you have another component of the same type, it'll have the same value as this one - as you have declared it as a constant, that might be the behavior you want, but in that case, you need not use data binding.
Amarghosh