28Апр/101
UINativeWindow
package ru.kozlovskij.air { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.NativeWindow; import flash.display.NativeWindowInitOptions; import flash.events.Event; import mx.core.IUIComponent; import mx.events.FlexEvent; import mx.managers.WindowedSystemManager; /** * Composition of <code>NativeWindow</code> and <code>IUIComponent</code>. * * @author Aleksandr.Kozlovskiy */ public class UINativeWindow extends NativeWindow { protected var systemManager:WindowedSystemManager; protected var childDisplayObject:IUIComponent; protected var rootDisplayObject:IUIComponent; /** * After initialization <code>childDisplayObject</code> added to <code>systemManager</code>'s displaylist. * * * @param initOptions:NativeWindowInitOptions - Analogically NativeWindow initOptions. * @param rootDisplayObject:IUIComponent - Root Application or other IUIComponent implementation. Mast extends DisplayObject. * @param childDisplayObject:IUIComponent - Container. Child Application or other IUIComponent implementation. Mast extends DisplayObject. * */ public function UINativeWindow(initOptions:NativeWindowInitOptions, rootDisplayObject:IUIComponent, childDisplayObject:IUIComponent) { super(initOptions); this.rootDisplayObject = rootDisplayObject; this.childDisplayObject = childDisplayObject; addChildren(); stage.addEventListener(Event.RESIZE, stageResizeHandler); } protected function addChildren():void { childDisplayObject.addEventListener(FlexEvent.CREATION_COMPLETE, childCreationCompleteHandler, false, 0, true); (stage.addChild(systemManager = new WindowedSystemManager(rootDisplayObject)) as DisplayObjectContainer) .addChild(childDisplayObject as DisplayObject); stageResizeHandler(); } protected function childCreationCompleteHandler(e:FlexEvent):void { childDisplayObject.removeEventListener(FlexEvent.CREATION_COMPLETE, childCreationCompleteHandler); stageResizeHandler(); } // ------------------ resize ----------------------- // protected function stageResizeHandler(e:Event = null):void { childDisplayObject.width = stage.stageWidth; childDisplayObject.height = stage.stageHeight; } } }
RAFPUG
UAFPUG
