tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/487-air-nativewindow-contextRobotlegs: Discussion 2012-03-30T08:58:58Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/138888602012-02-22T07:36:11Z2012-02-22T07:36:12ZAIR NativeWindow Context<div><p>I'm a newer to Robotlegs,I got a problem when I use the
framework on my AIR project.<br>
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.<br>
I need you help,thank you.</p></div>I've got a problem on HOW TO ORGANISE my projecttag:robotlegs.tenderapp.com,2009-10-18:Comment/138888602012-02-22T16:41:40Z2012-02-22T16:41:40ZAIR NativeWindow Context<div><p>Hello,</p>
<p>Take a look at this:<br>
<a href=
"http://www.ben-morris.com/howto-add-flex-mx-controls-to-a-nativewindow-for-adobe-air">
http://www.ben-morris.com/howto-add-flex-mx-controls-to-a-nativewin...</a></p>
<p>I’ve used ExtendedNativeWindow from the article above.</p>
<p>In your context class:<br>
mediatorMap.mapView(SomeView, SomeMediator, null, true, true);</p>
<p>mediatorMap.mapView(NativeContent, ApplicationMediator, null,
true, false);</p>
<p>where NativeContent is a Group container, that you’ll add
to your NativeWindow and SomeView is another component added to
NativeContent.<br>
<strong>NativeContent will be your contextView</strong>.</p>
<p>In your WindowedApplication you’d have a function, which
will create the NativeWindow, add NativeContent and set the
contextView to NativeContent.</p>
<pre>
<code>
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();
}</code>
</pre>
<p>Let us know whether that answered your question or not.<br>
Cheers,<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/138888602012-02-23T03:02:26Z2012-02-23T03:02:26ZAIR NativeWindow Context<div><p>Hi Ondina,<br>
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 ?</p></div>Nevertag:robotlegs.tenderapp.com,2009-10-18:Comment/138888602012-02-23T05:53:24Z2012-02-23T05:53:25ZAIR NativeWindow Context<div><p>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</p></div>Nevertag:robotlegs.tenderapp.com,2009-10-18:Comment/138888602012-02-23T10:30:06Z2012-02-23T10:37:15ZAIR NativeWindow Context<div><blockquote>
<p>Thank you very much.I've solved the problem successfully.</p>
</blockquote>
<p>You’re welcome, Never :)</p>
<blockquote>
<p>… maybe I should split my project to serveral modules,
each NativeContent has its own context and they contact each other
by robotlegs-utilities-Modular</p>
</blockquote>
<p>Yes, the modular utility would solve the problem of
communication between different windows.</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>In my example, the NativeContent ist he contextView.<br>
You can get a reference to the NativeWindow object through:<br>
<strong>this.stage.nativeWindow</strong> where <em>this</em> ist
the NativeContent.<br>
So, if you wanted to close your NativeWindow from within
NativeContent you could do this:</p>
<pre>
<code>
private function closeNativeWindow():void
{
//here perform some actions, if need be
//and then close the window
this.stage.nativeWindow.close();
}</code>
</pre>
<p>Ondina</p></div>Ondina D.F.