tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/244-trying-to-load-modular-swfs-into-a-modular-shellRobotlegs: Discussion 2012-02-02T11:24:19Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-10T16:57:46Z2011-01-10T16:57:47ZTrying To Load Modular SWF's into a Modular Shell <div><p>UPDATE*</p>
<p>I noticed that upon adding the module to my view component after
loading the swf in the shell, it seems to be somehow automatically
running the "set parentInjector()" method. So I removed the logic
where I manually set this... still no success though.</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-10T17:49:46Z2011-01-10T17:49:46ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hi Justin,</p>
<p>are you maybe setting the loading SWF's contextView in the
loaded<br>
SWF's module context's injector? That would be the only explanation
I<br>
can come up with right now.</p>
<p>Incidentally, I started writing some unit tests for
SwiftSuspenders'<br>
handling of applicationDomains in child injectors over the
weekend<br>
(and I can safely say that applicationDomains <em>don't</em> want
to be unit tested - at all!), so I would be very interested in
reduced test-cases<br>
of reproducible problems in this area.</p>
<p>If you can come up with such a reduced test-case, I'd gladly
take a<br>
look at the problem and fix related bugs in SwiftSuspenders,
should<br>
any turn up.</p>
<p>cheers,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-10T19:23:51Z2011-01-10T19:23:51ZTrying To Load Modular SWF's into a Modular Shell <div><p>Thanks for the quick response!</p>
<p>I'm not really following the first part, you asked:</p>
<p>"are you maybe setting the loading SWF's contextView in the
loaded SWF's module context's injector? That would be the only
explanation I<br>
can come up with right now."</p>
<p>I'm basically just loading in the module into the shell without
using a LoaderContext at the moment. In the shell context i'm
mapping the viewType as "IModule". When I load the module and right
when I add it to the stage it automatically calls the "set
parentInjector()" method that is being "Injected" into the modules
doc class, here i traced the value of the injector when it is
passed into the module to make sure it is not null, here's the
trace: "[object SwiftSuspendersInjector]" -it seems to be
successfully passing the injector. But for some reason, in the "set
parentInjector()", method injected into the modules doc class, when
I add in the code to create the context and I pass the context:
"(this, injector)", I get the ApplicationDomain.getDefinition()
error.</p>
<p>Thanks again!</p>
<p>Justin</p>
<p>Maybe I have to manually set something in the shell or in the
modules context.</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-10T19:29:57Z2011-01-10T19:29:58ZTrying To Load Modular SWF's into a Modular Shell <div><p>Oh the first part of the error I am receiving is this:</p>
<p>"Exception fault: ReferenceError: Error <a href=
"/discussions/problems/1065" title="Discussion #1065">#1065</a>:
Variable ModuleLandscape is not defined."</p>
<pre>
<code>at flash.system::ApplicationDomain/getDefinition()</code>
</pre>
<p>... where "ModuleLandscape" is the module swf that I am loading
in. So it seems as if it expects me to map the exact module type in
the shells context, but I already mapped the type of "IModule".</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-11T10:19:05Z2011-01-11T10:19:07ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hi Guys,</p>
<p>I think I've got the same problem here. I'm loading modules
dynamically in shell with ModuleManager and when I'm trying to use
child domain I'm getting a similar error.<br>
When I use current domain all is working but references like:
_ModuleName_mx_core_FlexModuleFactory prevent modules from being
able to fully unload. Using a child domain should fix this.</p>
<p>I modify an example I found somewhere to demonstrate this
error.</p>
<p>Thanks</p></div>Martintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-11T11:16:25Z2011-01-11T11:16:25ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hey Martin,</p>
<p>looking forward to your example. As I said, I'd really like to
debug<br>
and fix this.</p>
<p>cheers,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-11T13:50:51Z2011-01-11T13:50:51ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hey Till,</p>
<p>Fxp attached to last post. Thanks!</p>
<p>Would be great if Justin can look at it and let us know if
that's exactly same problem.</p></div>Martintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-11T14:21:19Z2011-01-11T14:21:19ZTrying To Load Modular SWF's into a Modular Shell <div><p>Thanks Martin, I didn't see the attachment. Will take a look and
see<br>
what I come up with.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-12T15:29:13Z2011-01-12T15:29:13ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hey Martin, I just downloaded that attachment and fired it up in
flash builder and it appears to be the exact same issue I am having
when trying to load a modular swf:</p>
<p>"ReferenceError: Error <a href="/discussions/problems/1065"
title="Discussion #1065">#1065</a>: Variable M2 is not
defined."</p>
<pre>
<code>at flash.system::ApplicationDomain/getDefinition()</code>
</pre>
<p>I am really curious to what this could be and how to fix it.</p>
<p>Thanks for posting your example! Hopefully we can find a
remedy.</p>
<p>-Justin</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-12T18:39:23Z2011-01-12T18:39:23ZTrying To Load Modular SWF's into a Modular Shell <div><p>I took some time to debug this today and found the reason and
a<br>
workaround for the described problem.</p>
<p>When instantiating loaded modules, Flex does some stuff that
leads to<br>
the module's loaderInfo not containing the module Loader's<br>
ApplicationDomain. Instead, it contains the main application's<br>
ApplicationDomain.</p>
<p>To work around this, you can change your module's context's<br>
constructor in one of two ways:</p>
<ol>
<li>
<p>If you're certain that your module will always be implemented as
a<br>
Flex module, you can use this:<br>
super(contextView, true, injector,<br>
contextView["moduleFactory"].info().currentDomain);</p>
</li>
<li>
<p>If, on the other hand, you want your context to be agnostic of
the<br>
module's exact implementation, you can use this:<br>
var applicationDomain : ApplicationDomain =<br>
(contextView["moduleFactory"] &&
contextView["moduleFactory"].info) ?
contextView["moduleFactory"].info().currentDomain :
contextView.loaderInfo.applicationDomain;<br>
super(contextView, true, injector, applicationDomain);</p>
</li>
</ol>
<p>The second solution performs a dynamic check for the existence
of<br>
information that Flex modules keep, while the first solution
just<br>
assumes the information exists.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-12T19:19:45Z2011-01-12T19:19:46ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hey Till, this looks great! Thanks for spending the time to do
this.</p>
<p>I am building a pure as3 project compiling with the FLex SDK but
i am not using the flex framework, so would you recommend that I
use the second "agnostic" approach?</p>
<p>I've tried it out and am getting an error when using the second
approach:</p>
<p>"Error <a href="/discussions/problems/1069" title=
"Discussion #1069">#1069</a>: Property moduleFactory not found on
..."</p>
<p>I am very confused about what "moduleFactory" is. Am I supposed
to swap that out with the type of my module or something?</p>
<p>Thanks again!</p>
<p>Justin</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-12T19:33:22Z2011-01-12T19:33:22ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hi Justin,</p>
<p>it sounds like your problem is actually unrelated to the one
Martin's<br>
example demonstrates.</p>
<p>I'm afraid I won't be able to help you without some kind of
example<br>
demonstrating <em>your</em> problem, then. If at all possible,
having a<br>
reduced test-case would be perfect, but if you can't manage to
create<br>
that, I would offer to have a look at your code instead. I'd
guarantee<br>
to keep it confidential of course if you send it to me in
private<br>
mail.</p>
<p>cheers,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-12T20:50:47Z2011-01-12T20:50:50ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hey Till, I just whipped up a simple project in Flash Builder
and am attaching the Flash Builder .zip project to this post.</p>
<p>All it is composed of is a Shell Module and a TestModule swf
that I load into the shell. If you run the the main application,
you would just need to click on the big red sprite to load in the
module swf, and then it gets added to the main sprite (the Document
class). This is when I get the error:</p>
<p>ReferenceError: Error <a href="/discussions/problems/1065"
title="Discussion #1065">#1065</a>: Variable TestModuleView is not
defined.<br></p>
<pre>
<code>at flash.system::ApplicationDomain/getDefinition()</code>
</pre>
<p>Again, thanks for your patience! I really appreciate all of your
help.</p>
<p>-Justin</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-13T10:09:56Z2011-01-13T10:09:56ZTrying To Load Modular SWF's into a Modular Shell <div><p>Thanks for the test-case, I'll have a go at it later today.</p>
<p>And don't worry about my patience. I see it as a division of
labor:<br>
You provide feedback and a test-case, I get a head-start in
debugging<br>
I wouldn't have got had I stumbled upon the problem in one of my
own<br>
projects.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-13T15:40:49Z2011-01-13T15:40:50ZTrying To Load Modular SWF's into a Modular Shell <div><p>Right on Till! Sounds good to me. I'm sure this issue is not too
terrible, I'm just surprised that this hasn't been an issue
before... that is, loading external RL module swfs into a modular
shell outside of the flex framework. Or at least not an issue that
has been solved and documented from what I can tell. I'm looking
forward to getting to the bottom of this one.</p></div>Justintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-14T12:30:46Z2011-01-14T12:30:47ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hey Till!!!</p>
<p>Thanks for a fix. It's working great. Shame it's not a solution
for Justin so extra thanks for double work. Must say that I'm
working on my first Robotlegs project and I absolutely love it!
Keep up great work!! Cheers</p></div>Martintag:robotlegs.tenderapp.com,2009-10-18:Comment/46571642011-01-24T00:00:10Z2011-01-24T00:00:10ZTrying To Load Modular SWF's into a Modular Shell <div><p>Hi Justin,</p>
<p>I'm really sorry for not replying earlier. I finally had a look
at<br>
your example and it seems like there are some things wrong with
it<br>
outside of anything the Injector does:</p>
<p>First of all, your constructor call to TestModuleContext is
wrong: The<br>
second parameter should be of type "Boolean" and tells the
context<br>
whether it should automatically start up after the view has been
added<br>
to the Stage. Unfortunately, this error is a bit hard to spot
because<br>
the compiler only warns about the injector you're providing as
the<br>
second parameter being coerced to a boolean value instead of
throwing<br>
an error.<br>
Just adding a "true" as the second parameter should fix this
problem.</p>
<p>Unfortunately, I'm afraid I won't be able to be of much help
with the<br>
second problem as I don't really know that much about Flex's
module<br>
support: Flex modules can't be loaded with a normal Loader,
you'll<br>
have to use a ModuleLoader instead. It might be a simple case
of<br>
changing the Loader to a ModuleLoader and recompiling, but I'm
not<br>
sure about that.</p>
<p>I'd recommend taking a look at Martin's now working example, as
it<br>
seems like it would show how to properly load Flex modules into
child<br>
ApplicationDomains.</p>
<p>cheers,<br>
till</p></div>Till Schneidereit