Calendar

March 2007
M T W T F S S
« Feb   Apr »
 1234
567891011
12131415161718
19202122232425
262728293031  

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments


« 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, 2007Print This Post Print This Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
333 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. <?xml version=”1.0″ encoding=”utf-8″?>
  2. <mx:ApolloApplication xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”200″ height=”100″>
  3.  
  4. <mx:Script>
  5. <![CDATA[
  6. private var newWindow:NativeWindow;
  7. private var component:MyComponent;
  8.  
  9. public function createWindow():void {
  10. newWindow = new NativeWindow( true, new NativeWindowInitOptions() );
  11. component = new MyComponent();
  12. hiddenCanvas.addChild( component );
  13. hiddenCanvas.removeChild( component );
  14. newWindow.stage.addChild( component );
  15. }
  16.  
  17. ]]>
  18. </mx:Script>
  19.  
  20. <mx:Button label=”Create A Window” click=”createWindow()” x=”38″ y=”25″/>
  21. <mx:Canvas id=”hiddenCanvas” visible=”false” />
  22. </mx:ApolloApplication>

MyComponent.mxml

  1. <?xml version=”1.0″ encoding=”utf-8″?>
  2. <mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” width=”350″ height=”100″>
  3. <mx:Label fontSize=”30text=”Hello World !” width=”100%” y=”22″/>
  4. </mx:Canvas>

Share/Save/Bookmark

Topics: Adobe AIR, Tutorials |

3 Responses to “Create your first Apollo Window”

  1. argv Says:
    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….

  2. everythingflex Says:
    March 22nd, 2007 at 6:16 am

    In the alpha, this is necessary to initialize the component before it is added to the window.

  3. argv Says:
    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….

Comments