Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
July 26, 2017, 05:36:43 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: Mediators adding their own View Components  (Read 3941 times)
caista
Newbie
*
Posts: 5


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

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: 2870



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

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 AM »

OK, brilliant thanks.

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



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

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