Quick tip: invalidating properties on bindables changed
By default, flex bindable properties fires event PropertyChangeEvent.PROPERTY_CHANGE. Sure, those events can be listened thus you can play with them. This can be useful when you have a lot of bindable properties in your classes and you do not want to make getter and setter for each just to be able to catch the moment of update:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
creationComplete="creationCompleteHandler()">
<mx:Script>
<![CDATA[
import mx.events.PropertyChangeEvent;
[Bindable] private var bVar:uint = 0;
[Bindable] private var btnLabel:String = "";
private function creationCompleteHandler():void
{
addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangedHandler);
}
private function propertyChangedHandler(event:PropertyChangeEvent):void
{
if(event.property == "bVar")
invalidateProperties();
}
override protected function commitProperties():void
{
super.commitProperties();
btnLabel = bVar.toString();
}
]]>
</mx:Script>
<mx:Button click="bVar++" label="{btnLabel}"/>
</mx:Application>