A data-binding watcher invokes an event listener when a binding occurs. : List Event « Components « Flex






A data-binding watcher invokes an event listener when a binding occurs.

A data-binding watcher invokes an event listener when a binding occurs.
           

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->


<!-- binding/DetectWatcher.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    initialize="initWatcher();">
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <fx:Script>
         
            import mx.binding.utils.*; 
            import mx.events.FlexEvent; 
            import mx.events.PropertyChangeEvent; 
            public var myWatcher:ChangeWatcher; 
            // Define binding watcher. 
            public function initWatcher():void { 
                // Define a watcher for the text binding. 
                ChangeWatcher.watch(textarea, "text", watcherListener); 
            } 
            // Event listener when binding occurs. 
            public function watcherListener(event:Event):void { 
                myTA1.text="binding occurred"; 
                // Use myWatcher.unwatch() to remove the watcher. 
            } 
          
    </fx:Script>
    <!-- Define a binding expression to watch. -->
    <s:TextInput id="textinput" text="Hello" />
    <s:TextArea id="textarea" text="{textinput.text}" />
    <!-- Trigger a binding. -->
    <s:Button label="Submit" click="textinput.text='Goodbye';" />
    <s:TextArea id="myTA1" />
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Change event for List controlChange event for List control
2.Adding an event listener if one isn't presentAdding an event listener if one isn't present
3.Event listener in an ActionScript function in an tagEvent listener in an ActionScript function in an <mx:Script> tag
4.List change eventList change event
5.Get selected item from a list from change eventGet selected item from a list from change event
6.Convert event target to List controlConvert event target to List control
7.Write your event listener to access the event objectWrite your event listener to access the event object
8.List dragOver, dragDrop, dragExit eventsList dragOver, dragDrop, dragExit events
9.List double click eventList double click event
10.Add an Event Listener in MXMLAdd an Event Listener in MXML