package oreilly.cookbook{ import flash.display.DisplayObject; import mx.core.UIComponent; import mx.states.IOverride; publicclass CustomOverride implements IOverride { privatevar widthValue:Number; privatevar _target:DisplayObject; publicfunction CustomOverride(target:DisplayObject = null) { _target = target; } publicfunction get target():DisplayObject { return _target; } publicfunction set target(value:DisplayObject):void { _target = value; } //empty publicfunction initialize():void {} //here we make sure to store the value of the parent before we change it //so that we can use this value in the remove method publicfunction apply(parent:UIComponent):void { widthValue = _target.width; if(_target.width > 500) { _target.width = 500; } } //here we use the stored value publicfunction remove(parent:UIComponent):void { _target.width = widthValue; } } }