OK, I think I see what is going on.

 

The app loads module one into a child domain.

 

MainAppDomain

                        ModuleOneAppDomain

 

The MainAppDomain is where ModuleManager is defined since there is a
ModuleLoader and other Module-related code in main.mxml.

 

When ModuleOne goes to load ModuleTwo, it is going to use the
ModuleManager code in MainAppDomain which is going to make a child
domain from the main app and not moduleOne.

 

MainAppDomain

                        ModuleOneAppDomain

                        ModuleTwoAppDomain

 

Not:

            MainAppDomain

                        ModuleOneAppDomain

                                    ModuleTwoAppDomain

 

 

And thus you are in the shared code topology.  That's why you need to
add your interfaces to the main app or use the shared code trick from my
blog, or specify the applicationDomain for ModuleOne somehow.

 

-Alex

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Michael Ritchie
Sent: Thursday, April 05, 2007 11:11 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Module Interface Problems

 

Alex,

I made a test case and also managed to get it to work. I realized two
things about the process. Within the main application I load the
module one (red) and module one loads module two (green). 

Module one needs to be cast as a ModuleLoader in the ready event
handler in the Main application in order for module two have a non
null pointer. You also seem to have to have the ModuleLoader in the
main application cast as the same Interface as the one module two
implements. I am not sure why though.

Changing either one of these parameters will produce the null pointer.
I have a working version of the test case posted, the zip file
contains both module one and module two project zip files as well. 

Example:

http://thanksmister.com/moduletest/main.html
<http://thanksmister.com/moduletest/main.html> 

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Can you post a test case?
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Michael Ritchie
> Sent: Thursday, April 05, 2007 11:00 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: Module Interface Problems
> 
> 
> 
> Alex,
> 
> Lol, you said "tickling", haha. Yes, this is within the same domain.
> Everything resides within the bin file of the main application, same
> level. It was loaded just fine and dispatched the progress and ready
> events. When you say "main class", do you meant the Module that is
> loading the second module. I got a little lost ModuleLoader loading
> ModuleLoaders module... makes my head spin.
> 
> -Mike
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> , "Alex Harui" <aharui@> wrote:
> >
> > If you don't make an instance of the main class in your module which
> > gets around to tickling the module's ModuleLoader, that ModuleLoader
> > won't load its module. Did you see it get loaded and dispatch READY?
> > 
> > This is all within a single domain right?
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of Michael Ritchie
> > Sent: Wednesday, April 04, 2007 12:40 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Module Interface Problems
> > 
> > 
> > 
> > In my context, a module loading another module using ModuleLoader. 
> > The reference to the child of the ModuleLoader is always null. I
have
> > even set up a timer event that keeps checking back to see if the
child
> > is not null. Is there something specific about what I am trying to
> > do that would cause the child to be null?
> > 
> > - Mike
> > 
> > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Alex Harui" <aharui@> wrote:
> > >
> > > ModuleLoader is a convenience container. It loads in the module
via
> > > ModuleManager and when READY, it starts to create the children. If
> you
> > > listen to READY you may see it before moduleloader had a chance to
> see
> > > it and create the child.
> > > 
> > > -Alex
> > > 
> > > ________________________________
> > > 
> > > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of Michael Ritchie
> > > Sent: Tuesday, April 03, 2007 1:04 PM
> > > To: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Re: Module Interface Problems
> > > 
> > > 
> > > 
> > > I ruled out the timing issue, but your post has some great
> information
> > > how to handle this. I think I have isolated the specific module
> > > loading issue to one factor. I have a module that loads another
> > > module using a <mx:ModuleLoader> and I am trying to access the
> second
> > > ModuleLoader child through the interface. I can't seem get a
> > > reference to the child of the second ModuleLoader, it always
reports
> > > null. I have a successfully loaded a module and talked using the
> > > interface, but if move this within the context of another module,
I
> > > get the null reference. 
> > > 
> > > --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > , "- FI / Jonas Eliasson +"
> > > <jonas.eliasson@> wrote:
> > > >
> > > > That sounds like a still existing Flash issue if you try to load
a
> > > swf that
> > > > has a shared library attached to it. Then you will get a loaded
> > > callback
> > > > before it's actually loaded. So in Flash you can check on the
> loaded
> > > event
> > > > if current frame == 0. In that case you can't access any
> properties
> > > and no
> > > > code will be executed yet. But you can still write to the
object.
> In
> > > our
> > > > scenario we have attached a callback event method. So when the
swf
> > > is really
> > > > loaded it will check if the callback exist and then execute it.
> > > Which will
> > > > tell the loader that it's ready to be initiated. Something
similar
> > > should be
> > > > easy to implement on the module but not with a check for a frame
> > > number :-)
> > > > . Should be a better solution for this. I don't want to go back
to
> > > old Flash
> > > > hacks hehe. 
> > > > 
> > > > 
> > > > 
> > > > //as2 example 
> > > > 
> > > > private function onLibraryLoaded(libraryClip:MovieClip,
> > > cb:CallBack):Void {
> > > > 
> > > > var me:SharedLibraryLoader = getInstance(); 
> > > > 
> > > > if(libraryClip._currentframe == 0){
> > > > 
> > > > libraryClip.onComplete = new CallBack(me,
> > > me.onLibraryInitiated,
> > > > null, cb);
> > > > 
> > > > }else
> > > > 
> > > > onLibraryInitiated(libraryClip, cb);
> > > > 
> > > > }
> > > > 
> > > > _____ 
> > > > 
> > > > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > ] On
> > > > Behalf Of Michael Ritchie
> > > > Sent: den 3 april 2007 11:24
> > > > To: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com> 
> > > > Subject: [flexcoders] Re: Module Interface Problems
> > > > 
> > > > 
> > > > 
> > > > From my experience there is a definite timing issue when loading
> > > > modules. The ModuleLoader ready event is fired before the Module
> is
> > > > fully loaded and you have the ability to talk to it through a
> common
> > > > interface (hence the error reporting access to a null value). 
> > > > 
> > > > I would term this one as a "bug" that is not yet documented by
> > Adobe.
> > > > This could be because some modules take longer than expected to
> > load,
> > > > I have no idea, just the observed problem with talking with
> modules
> > > > within the "ready". I also attempted to use an interface to talk
> > with
> > > > a module when the the progress event had reached 100%, but still
> no
> > > > luck. 
> > > > 
> > > > A possible workaround would be to fire some event from inside
the
> > > > loaded module that tells the outside world that it is indeed
> loaded.
> > 
> > > > The other option is to set a timer interval and keep checking if
> the
> > > > module is loaded (meaning not reporting NULL in the ready event
> > > > handler). Unless someone else as a viable solution? Adobe?
Anyone?
> > > > 
> > > > - mr
> > > > 
> > > > --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
> > > ups.com,
> > > > "kristian_wright2002"
> > > > <karnal69@> wrote:
> > > > >
> > > > > *BUMP*
> > > > > 
> > > > > Anyone have any ideas? I still haven't found a solution...
> > > > > 
> > > > > K.
> > > > >
> > > >
> > >
> >
>

 

Reply via email to