Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: External swf uses PureMVC framework ontop of existing framework.  (Read 9616 times)
deltajam
Courseware Beta
Full Member
***
Posts: 25


View Profile Email
« 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

Logged
ddragosd
Courseware Beta
Jr. Member
***
Posts: 10


View Profile Email
« Reply #1 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
Logged
deltajam
Courseware Beta
Full Member
***
Posts: 25


View Profile Email
« Reply #2 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
Logged
ddragosd
Courseware Beta
Jr. Member
***
Posts: 10


View Profile Email
« Reply #3 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
Logged
deltajam
Courseware Beta
Full Member
***
Posts: 25


View Profile Email
« Reply #4 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.
Logged
Pages: [1]
Print