Observe Utility listen’s property changes at run time on any assigned variable and calls its defined function. This utility does the same job as ChangeWatcher or BindingUtils. I prefer using this as its very light weight, fast and handy.
package org.util { /** * Detects changes to a value and runs a function in response. * @param source: Source value that is to be watched. * @param enabled:Prevents ObserveUtil firing before visual elements are available. * @param handler: Function that gets called when source property gets changed. * * @author Chouhan * */ public class ObserveUtil { public var handler:Function; public var enabled:Boolean =true; public function set source(source:*):void{ if(enabled){ handler.call(); } } } } USAGE: <util:Observe source="{valueThatIsToBeWatchedFor}" handler="{valueChangedFunction}" /> private function valueChangedFunction():void{ /* Implement your logic upon property change */ }
Hope you’ve had fun using this utility. !!