Bind to Properties by Using ActionScript : ActionScript « Development « Flex






Bind to Properties by Using ActionScript

Bind to Properties by Using ActionScript
          

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initHandler();">
    <mx:Script>
        
            import mx.binding.utils.ChangeWatcher;
            import mx.binding.utils.BindingUtils;

            private var myChangeWatcher:ChangeWatcher;

            private function initHandler():void
            {
                myChangeWatcher = BindingUtils.bindProperty( nameField, "text", nameInput, "text" );
            }
             private function clickHandler():void
             {
                 if( myChangeWatcher.isWatching() )
                 {
                     myChangeWatcher.unwatch();
                     btn.label = "watch";
                 }
                 else
                 {
                     myChangeWatcher.reset( nameInput );
                     btn.label = "unwatch";
                 }
             }
      
    </mx:Script>

    <mx:Panel title="User Entry.">
          <mx:Form>
                 <mx:FormItem label="Name:">
                       <mx:TextInput id="nameInput" />
                 </mx:FormItem>
          </mx:Form>
          <mx:Label text="You Entered:" fontWeight="bold" />
          <mx:HBox>
               <mx:Label text="First Name:" />
               <mx:Text id="nameField" />
          </mx:HBox>
          <mx:Button id="btn" label="unwatch" click="clickHandler();" />
    </mx:Panel>
</mx:Application>
    
    

   
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Use ActionScript to configure controlsUse ActionScript to configure controls
2.Applying behaviors in ActionScript with Resize classApplying behaviors in ActionScript with Resize class
3.Set target and targets properties in ActionScriptSet target and targets properties in ActionScript
4.Add controls with ActionScriptAdd controls with ActionScript
5.Load swf file with ModuleManager in ActionScriptLoad swf file with ModuleManager in ActionScript
6.Inline ActionScriptInline ActionScript
7.Setting Triggers With ActionScriptSetting Triggers With ActionScript
8.Set Properties of a Child Defined in MXML in ActionScriptSet Properties of a Child Defined in MXML in ActionScript
9.Specify an id value to refer to a component elsewhere in your MXML, either in another tag or in an ActionScript blockSpecify an id value to refer to a component elsewhere in your MXML, either in another tag or in an ActionScript block
10.Tags Are ClassesTags Are Classes
11.Attributes Are PropertiesAttributes Are Properties