« File and FileStream within Apollo – full source code | Main | Windowing with Apollo – full source code »
Create your first Apollo Window
| By Rich Tretola | March 19, 2007 | |
| 2,003 views |
Creating a window is very simple with Apollo. This is a very basic example of how to create a new window that contains a custom component. Simply create a new Apollo project within FlexBuilder and paste the following as the main file. Create a component named MyComponent.mxml and paste the code at the bottom of this post.
Main ApolloApplication file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?xml version=”1.0″ encoding=”utf-8″?> <mx:ApolloApplication xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”200″ height=”100″> <mx:Script> <![CDATA[ private var newWindow:NativeWindow; private var component:MyComponent; public function createWindow():void { newWindow = new NativeWindow( true, new NativeWindowInitOptions() ); component = new MyComponent(); hiddenCanvas.addChild( component ); hiddenCanvas.removeChild( component ); newWindow.stage.addChild( component ); } ]]> </mx:Script> <mx:Button label=”Create A Window” click=”createWindow()” x=”38″ y=”25″/> <mx:Canvas id=”hiddenCanvas” visible=”false” /> </mx:ApolloApplication> |
MyComponent.mxml
1 2 3 4 | <?xml version=”1.0″ encoding=”utf-8″?> <mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” width=”350″ height=”100″> <mx:Label fontSize=”30″ text=”Hello World !” width=”100%” y=”22″/> </mx:Canvas> |
Topics: Adobe AIR, Tutorials | 3 Comments »








March 22nd, 2007 at 5:28 am
Why you write this:
hiddenCanvas.addChild( component );
hiddenCanvas.removeChild( component );
so i tryed to create a new native window with content, but onle the natvieWindow appears not the content….
Reply to this comment
March 22nd, 2007 at 6:16 am
In the alpha, this is necessary to initialize the component before it is added to the window.
Reply to this comment
March 22nd, 2007 at 6:52 am
But it doesn’t work with other extendet Components like the Panel-Control, so i exchange the canvas with a Panel-Control and i see nothing….
Reply to this comment