/** * @author Paul Brooks Andrus * Creative Commons License * http://creativecommons.org/licenses/by/2.5/ * This work is licensed under a Creative Commons Attribution 2.5 License * June 6, 2005 */ import mx.events.EventDispatcher; import mx.utils.Delegate; class Watcher { function dispatchEvent(){}; function addEventListener(){}; function removeEventListener(){}; function Watcher() { EventDispatcher.initialize(this); } /* * Creates a watched property using the scope of the first parameter * */ public function watchProp(scope:Object, prop:String):Void { scope.watch(prop, Delegate.create(this,returnProperty), scope); } /* * Removes the watch from the scope defined by the 4th parameter, returns * the new value of the watched property and dispatches an event object * with all the information from the watch * */ public function returnProperty(prop:String, oldVal:String, newVal:String, scope:Object) { scope.unwatch(prop); dispatchEvent({type:"change", property:prop,value:newVal,oldValue:oldVal}); return newVal; } }