Home > Uncategorized > PureMVC Loading PureMVC

PureMVC Loading PureMVC

January 16, 2008

In large-scale applications, it is often useful to create independent micro-applications that serve almost as ‘plug-ins’. Suppose a micro-application is developed with PureMVC and is to be loaded into another application itself written in PureMVC. It is useful to think about a well-defined interface for allowing the loading application to provide data to the loaded micro-application and delay the Startup Notification until after loading and data initialization. One thing that’s easy to forget (like I did when copying and pasting code) is to ensure the Loader loads the micro-application into a separate ApplicationDomain (old-school we used to call it function table before these newfangled OOP languages).

PureMVC implements the Facade as a Singleton. If the micro-application is loaded with a context of ApplicationDomain.currentDomain, the loaded Facade will reference the already existing instance present in the loading application (as they both reference the Facade class). Instead, use some thing like,

var urlRequest:URLRequest = new URLRequest(_file);

var loaderContext:LoaderContext = new LoaderContext();
loaderContext.applicationDomain = new ApplicationDomain();

__loader.load(urlRequest, loaderContext);

Then, the Facade from the loaded Object will not conflict with that from the loading application. Simple point, but easy to forget, especially when copying loading code from another application into a new Proxy. Hope it saves you some time.

Categories: Uncategorized
  1. January 16, 2008 at 10:39 am

    great tip, I bet I’ll come back to this one day when I’m pulling my hair out…

  2. January 16, 2008 at 2:54 pm

    Another nice point thankyou

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: