PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: asbin on January 14, 2009, 08:54:14



Title: How to register mediator to a runtime viewCompontent?
Post by: asbin on January 14, 2009, 08:54:14
Hi,guys

now i have a question in programming.

so normally i register a MediatorClass in startCommand  like this:

:
var app:mainApp = notification.getBody() as mainApp ;
                        facade.registerMediator(new ApplicationMediator(app));
                        facade.registerMediator(new LoginMediator(app.Login));

but how to register a MediatorClass for a ViewCompontent what added to App stage in runtime?

like this compontent in mxml:

:
in my application.mxml script...

var myChatPanel:ChatPanel = new ChatPanel();
addChild(myChatPanel);


how can i register MediatorClass for this UIcompontent...

that's all ~~   :-\


Title: Re: How to register mediator to a runtime viewCompontent
Post by: puremvc on January 16, 2009, 08:48:17

You could capture the event sent when you add your child to the stage in a mediator that's listening for it and wrap the mediator around the reference to the added child andd register it.

Have a look at the slacker demo, which deals with deferred instantiaton.

In Slacker, the children of a ViewStack are only created when they are navigated to, and the viewStack's mediator listens for the event when the new child is created.

-=Cliff>


Title: Re: How to register mediator to a runtime viewCompontent?
Post by: asbin on January 17, 2009, 04:52:49
OK,I'll try this way! Thank you Cliff. :-*