FlashImp Flash Implosion new generation

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;
		}
	}
}
Комментарии (1) Пинги (0)
  1. For example:

    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
    					   xmlns:s="library://ns.adobe.com/flex/spark" 
    					   xmlns:mx="library://ns.adobe.com/flex/mx"
     
    					   autoExit="false"
    					   visible="false"
    					   creationComplete="creationCompleteHandler();"
    					   >
    	<fx:Script>
    		<![CDATA[
    			import mx.core.UIComponent;
    			import mx.events.FlexEvent;
     
    			public var newWindow:UINativeWindow;
    			protected function creationCompleteHandler():void
    			{
    				nativeWindow.close();
     
    				const options:NativeWindowInitOptions = new NativeWindowInitOptions();
    				options.systemChrome = NativeWindowSystemChrome.NONE;
     
    				newWindow = new UINativeWindow(options, this, new WindowedApplication()/* or new Panel() */);
    				newWindow.activate();
    			}
     
    		]]>
    	</fx:Script>
    </s:WindowedApplication>

Оставить комментарий

Вы должны войти в систему чтобы публиковать комментарии.

Нет обратных ссылок на эту запись.