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]
Print
Author Topic: Mediators adding their own View Components  (Read 9293 times)
caista
Newbie
*
Posts: 5


View Profile Email
« on: August 31, 2011, 06:22:40 »

Hello

Now I know this can be done and is not bad practice, but I can't work out how to do it.

Obviously a Mediator can be registered without a viewComponent. But then say I want the mediator to respond to a Notification and add it's own viewComponent, how would it do this?

It won't have any reference to a DisplayObject to add the viewComponent to.

I hope this makes sense. I have searched the forum and can't find a simple answer to this.

Thanks in advance
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: August 31, 2011, 08:16:29 »

Have it respond to a notification by instantiating the view component, setting its own reference to that view component and then send it off in another notification that a StageMediator (or the appropriate mediator whose view component you want to inject this one into) hears. The StageMediator might listen for an ADD_TO_STAGE notification, for instance, and respond by taking the component out of the note, cast to DisplayObject and do an addChild on its Stage reference.
Logged
caista
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: September 01, 2011, 07:30:42 »

OK, brilliant thanks.

Presumably I could use the ApplicationMediator rather thatn creating a StageMediator.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: September 01, 2011, 07:53:18 »

Yep, that'll usually do.
Logged
Pages: [1]
Print