监听变量变化
<?xml version="1.0" encoding="utf-8"?>
<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" minWidth="955" minHeight="600"creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.binding.utils.ChangeWatcher;import mx.controls.Alert;import mx.events.FlexEvent;[Bindable]public var aaa:String="123";protected function application1_creationCompleteHandler(event:FlexEvent):void{
ChangeWatcher.watch(this,"aaa",nnnn);aaa="789";
}public function nnnn(event:Event):void{
Alert.show(aaa);
}
]]>
</fx:Script>
</s:Application>
----------------------------------------------------------------------------------------
监听控件属性变化
<?xml version="1.0" encoding="utf-8"?>
<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" minWidth="955" minHeight="600"creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.binding.utils.ChangeWatcher;import mx.controls.Alert;import mx.events.FlexEvent;protected function application1_creationCompleteHandler(event:FlexEvent):void{
ChangeWatcher.watch(personName,"text",nnnn);
}public function nnnn(event:Event):void{
Alert.show(personName.text);
}
]]>
</fx:Script><s:TextInput id="personName" text="123"></s:TextInput>
</s:Application>