Mega Code Archive

 
Categories / Flex / Data Model
 

Create Customized Bindable Properties

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">        <mx:Script>                        private var _firstName:String;             public static const FIRST_NAME_CHANGED:String = "firstNameChanged";             private function clickHandler():void             {                 firstName = fnInput.text;             }             [Bindable(event="firstNameChanged")]             public function get firstName():String             {                 return _firstName;             }             public function set firstName( str:String ):void             {                  _firstName = str;                  dispatchEvent( new Event( FIRST_NAME_CHANGED ) );             }            </mx:Script>     <mx:Panel title="User Entry.">         <mx:HBox>             <mx:Label text="First Name:" />             <mx:TextInput id="fnInput" />         </mx:HBox>         <mx:Button label="submit" click="clickHandler();" />         <mx:Label text="You Entered:" />         <mx:HBox>             <mx:Label text="First Name:" />             <mx:Text text="{firstName}" />         </mx:HBox>     </mx:Panel> </mx:Application>