tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/3319-modules-in-a-popup-or-should-i-say-popup-modulesRobotlegs: Discussion 2013-06-27T07:58:58Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/274107032013-06-20T08:11:42Z2013-06-20T08:11:42ZModules in a Popup (or should I say Popup Modules?)<div><p>Hello,</p>
<blockquote>
<p>Any help here would be MUCH appreciated! Hopefully I'm not the
only one that wants to have mediated modules as a popup. – Am
I?</p>
</blockquote>
<p>No, you’re not the only one wanting that :)<br>
I’m also interested in Modules, Popups, Windows &Co.<br>
I was able to load Modules in a popup window and let them
communicate with other Modules and/or the shell. I’m using
Flex.</p>
<pre>
<code>var titleWindowInstance:PopUpModuleView = new PopUpModuleView();
viewManager.addContainer(titleWindowInstance);
PopUpManager.addPopUp(titleWindowInstance, FlexGlobals.topLevelApplication as DisplayObject);
PopUpManager.centerPopUp(titleWindowInstance);</code>
</pre>
<p>PopUpModuleView is then loading the Module.</p>
<p>In rl2 you’ll need the viewManager to manage the popup and
the ModularConnector for intermodular communication.</p>
<p><a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/553-viewmanager-what-is-it-for#comment_21538819">
http://knowledge.robotlegs.org/discussions/robotlegs-2/553-viewmana...</a></p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/viewManager">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a></p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/modularity">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a></p>
<p>I’ll tell you more about this later on today, if you
want.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274107032013-06-20T14:24:59Z2013-06-20T14:24:59ZModules in a Popup (or should I say Popup Modules?)<div><p>Hey Beau,</p>
<p>I've attached an example of a Module loaded inside a popup
window. Please see this post:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/3327-go-modular-for-multiple-games#comment_27416742">
http://knowledge.robotlegs.org/discussions/robotlegs-2/3327-go-modu...</a></p>
<p>Let me know, if it helped.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274107032013-06-20T23:14:09Z2013-06-20T23:14:09ZModules in a Popup (or should I say Popup Modules?)<div><p>Ondina,</p>
<p>It's been said many times before but I still have to say... YOU
ROCK! Your example and references are a big help!</p>
<p>Your <a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/3327-go-modular-for-multiple-games#comment_27416742">
example</a> raised a few questions for me.</p>
<p>First, I see you initialize the context from within an
onCreationComplete handler vs. in MXML within a tag. Is there a
benefit to doing it this way vs. the other?</p>
<p>Second, have you seen any memory or performance issues doing
this on a larger scale? Any insight on unloading the modules
effectively? I know this has been discussed and there are a number
of discussions about the StyleManager holding references, etc....
but just wanted to see if there is a final BEST PRACTICE approach
to this.</p></div>beaubrewertag:robotlegs.tenderapp.com,2009-10-18:Comment/274107032013-06-21T09:14:52Z2013-06-21T09:14:52ZModules in a Popup (or should I say Popup Modules?)<div><p>Wow, thank you. You made me blush :) Who doesn't want to hear
nice things about themselves once in awhile?</p>
<blockquote>
<p>First, I see you initialize the context from within an
onCreationComplete handler vs. in MXML within a tag. Is there a<br>
benefit to doing it this way vs. the other?</p>
</blockquote>
<p>It’s just a matter of preferences. Having the context
initialization in actionscript makes it easy to use the same code
in a pure as3 project as well.</p>
<blockquote>
<p>Second, have you seen any memory or performance issues doing
this on a larger scale?</p>
</blockquote>
<p>Do you mean because of the way the context was initialized? If
so, I haven’t encountered any issues until now, not even in
large scale projects.</p>
<blockquote>
<p>Any insight on unloading the modules effectively?</p>
</blockquote>
<p>I’ve became quite obsessed with GC &Co over the years
;)<br>
I don’t know of any ultimate best practices; I can only share
my experience and lots of links to articles on gc/
memory/performance. If you want, I can give you the links, but
I’m sure you’ve already read a lot on the subject.</p>
<p>Some general rules that I follow:</p>
<ul>
<li>
<p>before removing the View from the stage, remove all event
listeners;</p>
</li>
<li>
<p>if you use bindings for properties, data providers etc, make
sure they don’t keep the view alive in a way or another</p>
</li>
<li>
<p>same with dictionaries, styles (as you know), itemRenderers</p>
</li>
<li>
<p>using a profiler (I’m using FlashBuilder’s Profiler)
helps you identify the objects holding a reference to a class;</p>
</li>
<li>
<p>make sure the View isn’t referenced elsewhere in your app,
for example in a Model’s dictionary</p>
</li>
<li>
<p>if you add a View like this:</p>
<pre>
<code>private var:someView:SomeView;
private function addSomeViews():void
{
someView = new SomeView();
someContainer.addElement(someView);
}</code>
</pre></li>
</ul>
<p>because someView is declared outside the function, there will be
a reference to it, thus it won’t get gc-ed when you remove
someView from stage, w/o setting it to null. So, the scope of
variables is also important.</p>
<ul>
<li>With popups, don’t forget to remove the popup from the
viewManager.</li>
</ul>
<p>That’s all that comes to my mind right now. I’ll
make sure to write comments regarding gc in my example and a readme
on github. If you want to contribute, you can go through the
discussions on this forum and gather the tips and suggestions
concerning gc+memory, summarize them in here, and I’ll add
them to the readme (mentioning your contribution).<br>
Of course, only if your time permits!!</p>
<p>Also, look at Hans’ tips on gc:<br>
<a href=
"https://github.com/dotdotcommadot/ModularRL">https://github.com/dotdotcommadot/ModularRL</a></p>
<p>Thanks again for your kind words:)<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/274107032013-06-27T07:58:56Z2013-06-27T07:58:56ZModules in a Popup (or should I say Popup Modules?)<div><p>Hey Beau, you can re-open this discussion, if need be.</p></div>Ondina D.F.