Bindable event : Bindable Event « Data Model « Flex






Bindable event

Bindable event
           

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    
    import flash.events.Event;
    [Bindable(event="myValueChanged")]
    private function isEnabled():String {
      if (myValue)
        return 'true';
      else
        return 'false';
    }
    private var _myValue:Boolean = false;
    public function set myValue(value:Boolean):void {
      _myValue = value;
      dispatchEvent(new Event("myValueChanged"));
    }
    public function get myValue():Boolean {
      return _myValue;
    }
  </mx:Script>
  <mx:TextArea id="myTA" text="{isEnabled()}" />
  <mx:Button label="Clear MyFlag" click="myValue=false;" />
  <mx:Button label="Set MyFlag" click="myValue=true;" />
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Fire bindable event during value settingFire bindable event during value setting
2.Use [Bindable] metadata tag to specify to Flex to invoke the isEnabled()function in response to the event myFlagChanged.Use [Bindable] metadata tag to specify to Flex to invoke the isEnabled()function in response to the event myFlagChanged.
3.Bindable event and propertyBindable event and property
4.Dispatch Bindable eventDispatch Bindable event