PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: wersling on November 13, 2007, 04:42:39

Title: How dispose multi-instance sended Notification?
Post by: wersling on November 13, 2007, 04:42:39
Hi Cliff,
I have a issue:
I created a Loader(attach), it have a basic-class(BasicLoader) and two child classes(XMLLoader and SWFLoader), on a file loaded, it will send Notification.

A issue present to now, Is the XMLLoader and SWFLoader need different notification name?
If i need create two XMLLoader instance,not i need different commands to deal with them separately at the request. what's can i do?

-Sean Zou

Title: Re: How dispose multi-instance sended Notification?
Post by: puremvc on November 13, 2007, 07:57:38
Sounds like you just need to be able to specify the completion notification to be sent at runtime. Also, I'm assuming BasicLoader extends Proxy or Notifier since it sends notifications. Try this:

Give the BasicLoader a private property called completeNotification:String, inherited by XMLLoader and SWFLoader.

Also add a constructor parameter to BasicLoader of the same name and type.

When the XMLLoader or SWFLoader are constructed, pass in the unique notification name you wish that class to send when its onLoadComplete method is called.

var xmlLoader:XMLLoader = new XMLLoader(..., ApplicationFacade.MY_COMPLETE_NOTE);

Inside the BasicLoader constructor:

this.completionNotification =  completionNotification;

Then inside onLoadComplete of the BasicLoader, simply send the completeNotification instead of a literal string.


If sending the notification was all the onLoadComplete methods did, then remove them from the subclasses, as they are no longer needed.

Otherwise call super.onLoadComplete(event) at the end of your subclass onLoadComplete method to be sure the notification is sent.