PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: deltajam on December 10, 2007, 07:07:25



Title: External swf uses PureMVC framework ontop of existing framework.
Post by: deltajam on December 10, 2007, 07:07:25
I have one "Main" swf that loads a bunch of other swf files into it.  "Main" has a ApplicationFacade Class that initializes the concrete Facade.

One of the swf files, "Introduction", is complex and is also built using the PureMVC framework, has an Application Facade class, and initializes the concrete facade.

My problem, is that since the root swf "Main" has already initialized the Facade, I'm unable to load my external swf "Introduction" on top, because this line:
:
var facade:ApplicationFacade = ApplicationFacade.getInstance();
// Send the STARTUP notification
var note:Notification = new Notification( ApplicationFacade.APP_STARTUP, this);
facade.notifyObservers(note);
// facade returns NULL meaning that another instance of it was already created

..returns null, because it sees that:
:
       public static function getInstance(): ApplicationFacade {
            if ( instance == null ) {
instance = new ApplicationFacade( );
}
            return instance as ApplicationFacade;
        }

...instance is NOT null, and when "return instance as ApplicationFacade", it returns null.


How do I go about this?  Both Main and Introduction trying to access the concrete org.puremvc.patterns.facade.Facade class. 

Thanks,

Ty



Title: Re: External swf uses PureMVC framework ontop of existing framework.
Post by: ddragosd on December 11, 2007, 04:28:07
Hi Ty,
Are you working with modules ?

The ApplicationDomain should actually create two instances of ApplicationFacade for each swf you're loading. Did you try compiling the swf that you're loading, excluding the common classes ?

If you're interested to find more information about how flash player manages individual swfs you can review this link: http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000327.html

Dragos


Title: Re: External swf uses PureMVC framework ontop of existing framework.
Post by: deltajam on December 11, 2007, 08:46:05
Dragos,

I really appreciate your reply!  That is exactly what I needed to be reminded of.  Right now, I'm loading everything inside the currentDomain, and therefore none of the "Introduction" class definitions are partitioned from the "Main" definitions.  What I need to do is create a new ApplicationDomain when loading.

Thanks again!

Ty


Title: Re: External swf uses PureMVC framework ontop of existing framework.
Post by: ddragosd on December 11, 2007, 09:52:46
Hi Ty !

Loading the swf into a new ApplicationDomain should create distinct ApplicationFacades for each swf. Is that what you were looking for ?

Dragos


Title: Re: External swf uses PureMVC framework ontop of existing framework.
Post by: deltajam on December 11, 2007, 10:07:25
Yes, yes.  Sorry, I was a bit vague in my reply.  Looking closer at the ApplicationDomain class solved my problem.  Thanks.