I need to dynamically bind properties of components created at runtime. In this particular case, please suggest that I need to use bindProperty.
I do not quite understand why the following simplified test does not work (see code). When I click the button, the text of the label does not change.
I understand that in this particular example there are simpler ways to use traditional non-dynamic binding, but I need to understand this in terms of using bindProperty.
Can someone please help me understand what I am missing?
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="Tools.*" minWidth="684" minHeight="484" xmlns:ns2="*" creationComplete="Init();">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.binding.utils.*;
public var Available:ArrayCollection=new ArrayCollection();
public function get Value():String {
return (Available.getItemAt(0).toString());
}
public function Init():void {
Available.addItemAt('Before', 0);
BindingUtils.bindProperty(Lab, 'text', this, 'Value');
}
public function Test():void {
Available.setItemAt('After', 0);
}
]]>
</mx:Script>
<mx:Label x="142" y="51" id="Lab"/>
<mx:Button x="142" y="157" label="Button" click="Test();"/>
</mx:WindowedApplication>
Thanks in advance.
source
share