AIR NativeWindow Context

I've got a problem on HOW TO ORGANISE my project's Avatar

I've got a problem on HOW TO ORGANISE my project

22 Feb, 2012 07:36 AM

I'm a newer to Robotlegs,I got a problem when I use the framework on my AIR project.
As everyone know,A AIR project need a main mxml,in this mxml,I make the default nativeWindow to be hidden ,and open a new NativeWindow,then put all my other views(mxml) into this new NativeWindow.So when I new context,I can't get the correct contextView,because all my views are all in another NativeWindow not the default NativeWindow.
I need you help,thank you.

  1. Support Staff 1 Posted by Ondina D.F. on 22 Feb, 2012 04:41 PM

    Ondina D.F.'s Avatar

    Hello,

    Take a look at this:
    http://www.ben-morris.com/howto-add-flex-mx-controls-to-a-nativewin...

    I’ve used ExtendedNativeWindow from the article above.

    In your context class:
    mediatorMap.mapView(SomeView, SomeMediator, null, true, true);

    mediatorMap.mapView(NativeContent, ApplicationMediator, null, true, false);

    where NativeContent is a Group container, that you’ll add to your NativeWindow and SomeView is another component added to NativeContent.
    NativeContent will be your contextView.

    In your WindowedApplication you’d have a function, which will create the NativeWindow, add NativeContent and set the contextView to NativeContent.

    
    private var context:ApplicationContext;
    private var popupWindow:ExtendedNativeWindow;
    
    private function createPopupWindow():void
    {
    //* Set up the NativeWindow options
    var options:NativeWindowInitOptions = new NativeWindowInitOptions();
                    
    //* Create the NativeWindow
    popupWindow = new ExtendedNativeWindow(options);
                    
    //* Set the height, width and position
    popupWindow.width = 400;
    popupWindow.height = 300;
    popupWindow.x = ( Screen.mainScreen.bounds.width - 400) / 2;
    popupWindow.y = ( Screen.mainScreen.bounds.height - 300) / 2;
    popupWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
    popupWindow.stage.align = StageAlign.TOP_LEFT;
                    
                    
    //* Create an instance of the content for the NativeWindow
    var content:NativeContent=new NativeContent(); // a Group container
    var someView:SomeView = new SomeView();//a panel with a list
    content.addElement(someView);
    
    //*context !!!!
    context=new ApplicationContext(content);//the NativeContent Group
    
    //* Pass the content into the native window
    popupWindow.addChildControls(content);
                    
    //* Activate the window
    popupWindow.activate();                             
    }
    

    Let us know whether that answered your question or not.
    Cheers,
    Ondina

  2. 2 Posted by Never on 23 Feb, 2012 03:02 AM

    Never's Avatar

    Hi Ondina,
    Thank you very much.I've solved the problem successfully.However,another problem arises,I found that more than one NativeWindow I have constructed,It means there are serveral NativeContent Classes (I don't have this Class,I consider this Class may Inheritance UIComponent,am I right ?) you mentioned above,maybe I should split my project to serveral modules, each NativeContent has its own context and they contact each other by robotlegs-utilities-Modular ?

  3. 3 Posted by Never on 23 Feb, 2012 05:53 AM

    Never's Avatar

    I got another quesion in the context,Ondina,I just follow your method to construct the context,but I can't get the content's NativeWindow, I can only get the content,I think you can take what I mean.Thank you

  4. Support Staff 4 Posted by Ondina D.F. on 23 Feb, 2012 10:30 AM

    Ondina D.F.'s Avatar

    Thank you very much.I've solved the problem successfully.

    You’re welcome, Never :)

    … maybe I should split my project to serveral modules, each NativeContent has its own context and they contact each other by robotlegs-utilities-Modular

    Yes, the modular utility would solve the problem of communication between different windows.

    I just follow your method to construct the context,but I can't get the content's NativeWindow, I can only get the content,I think you can take what I mean.

    In my example, the NativeContent ist he contextView.
    You can get a reference to the NativeWindow object through:
    this.stage.nativeWindow where this ist the NativeContent.
    So, if you wanted to close your NativeWindow from within NativeContent you could do this:

    
    private function closeNativeWindow():void
    {
    //here perform some actions, if need be
    //and then close the window
    this.stage.nativeWindow.close();
    }
    

    Ondina

  5. Ondina D.F. closed this discussion on 30 Mar, 2012 08:58 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac