/** * ZStage * Message Broadcaster for stage resizing * * @author Zeh Fernando * @version 1.0.0 - 2/jul/2006 - First version */ /* Usage: zeh.extensions.ZStage.addListener(this); this.onResize = function() { trace ("onResize"); }; this.onStartResize = function() { trace ("onStartResize"); }; this.onStopResize = function() { trace ("onStopResize"); }; */ class zeh.extensions.ZStage extends zeh.events.BasicListener { private static var _initialized:Boolean; // Whether or not it has been initialized private static var iid:Number; // Interval id private static var DEFAULT_DELAY:Number = 100; // Default time to wait for resizing to stop /** * There's no constructor. */ public function StageResizer () { trace ("This is an static class and should not be instantiated.") } /** * Initializes the class */ private static function initialize(): Void { Stage.addListener(ZStage); _initialized = true; reset(); } private static function reset(): Void { if (iid != null) clearInterval(iid); iid = null; } public static function addListener(p_obj:Object): Void { if (!_initialized) initialize(); // super.addListener(p_obj); ??? doesn't work... if (_listeners == undefined) _listeners = new Array(); _listeners.push(p_obj); } public static function onResize(): Void { if (iid == undefined) broadcastMessage("onStartResize"); clearInterval(iid); iid = setInterval(ZStage.onStopResizing, 100); broadcastMessage("onResize"); } public static function onStopResizing(): Void { broadcastMessage("onStopResize"); reset(); } }