PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: rpereira on March 13, 2008, 07:49:29

Title: registering Commands in different SWFs (Flash)
Post by: rpereira on March 13, 2008, 07:49:29

Building a website with PureMVC.

My question regards best practices.

Due to size requirements I need to put code regarding a section of the website in the swf that corresponds to that section. If someone wants to see the news everything related to news is in the called on the news.fla

When the news.swf is loaded into the main Application I call the facade and instantiate Mediators, Proxies and Commands.

I all works beautifuly.

If I navigate into another portion of the website and return to news the commands are executed twice (or the number of times I have loaded the news.swf)

I managed to remove the mediators and proxies on unload of the news swf but I cannot remove the commands without digging into the framework.

Solutions I've come up with:

1. I could register the commands on the facade but it seems reasonable that the main swf does not need to instantiate everything when only a portion is needed.

2. I can also create a util singleton and flag the commands registered so they don't get registered again.

3. I also noted that Controller has a method removeCommand but I don't see it beeing used anywhere and through the facade I don't have access to it. Maybe one could be implemented

Any help on how this should be done would be greatly appreciated.

Thank you very much for PureMVC

Title: Re: registering Commands in different SWFs (Flash)
Post by: puremvc on March 13, 2008, 11:20:14

This is a known issue, and will be fixed in the next release of the Standard version. See the bottom of the Release Notes here: http://trac.puremvc.org/PureMVC_AS3/wiki/ReleaseNotes.

However, you might want to do some experimentation with the MultiCore Version.

It allows each SWF or Flex Module to have its own set of MVCF actors (a 'Core'). You will not have to remove all the Commands, Mediators and Proxies when you unload a SWF. You can remove the entire PureMVC Core for the swf by doing facade.removeCore().