1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
initialize="onInit()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.binding.utils.ChangeWatcher;
[Bindable]
public var counter:Number = 0;
private function onInit():void {
ChangeWatcher.watch(this, "counter", onDataChange);
}
private function onDataChange(e:Event):void {
Alert.show(counter.toString(),"Data change");
}
private function onClick():void {
counter = 5;
}
]]>
</mx:Script>
<mx:Button label="Change data" click="onClick()" />
</mx:Application> |
Partager