How do I get databinding to work in textinput?
In this example below, I have a TextInput defined with the text bound to
{userName}, when I run the app, and enter text into the TextInput field, I
would like the text entered assigned to the Bindable character string userName,
however it is not. What's the proper way to do this?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
[Bindable]
private var userName:String;
private function getName(event:Event):void {
trace('Username is: ' + userName);
}
]]>
</mx:Script>
<mx:TextInput x="46" y="42" id="myName_ti" text="{userName}"/>
<mx:Button x="246" y="42" label="Button" id="myButton"
click="getName(event)"/>
</mx:Application>