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]
Author Topic: How dispose multi-instance sended Notification?  (Read 3647 times)
Posts: 1

View Profile Email
« 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
Global Moderator
Hero Member
Posts: 2871

View Profile WWW Email
« Reply #1 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.

« Last Edit: November 13, 2007, 08:04:53 by puremvc » Logged
Pages: [1]