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: Stage resizing  (Read 7936 times)
hesten
Sr. Member
****
Posts: 52


View Profile Email
« on: July 06, 2009, 04:21:06 »

Hi

I am building an application that needs to run "fullscreen" (as in fullscreen within the browser, not a "take over"). When the window is resized the different elements obviously needs to reposition.

For this I use at StageMediator, whose viewComponents is stage. The StageMediator listens for the RESIZE event and sends a ApplicationFacade.STAGE_RESIZED notification.

Every other mediator that controls a view component that needs to reposition naturally listens for this notification.

Heres my concern, should the repositioning logic be in the view component or in the mediator? It seems that if I put it in the component it breaks some of the reuseability as you cannot assume that a component needs these things?
If I put it in the meditors the begin to more than merely mediate, which seems to break best practice?

Does it make sense?

Regards
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: July 06, 2009, 06:07:47 »

Resizing is definetly a function of the view component. There shouldn't be any "logic" in your mediators. I'd also recommend having a view component listen for stage events itself, rather than dispatching an event through PMVC. All components on the display list have access to the stage to add event listeners to.
Logged
hesten
Sr. Member
****
Posts: 52


View Profile Email
« Reply #2 on: July 06, 2009, 06:51:13 »

Yeah that makes sense. And you're absolutely right that components themselves should register for stage events instead of sending notifications.

(on a side note, do you know if a loaded swf file would contain 2 stage objects one for each swf (the loading file and the loaded file).

Thanks a lot, that just simplified things a bit :)
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #3 on: July 06, 2009, 08:22:27 »

There is only ever one stage in a flash application, regardless of how many modules/SWF's are loaded. THey all point to the same "root" stage.

Just have your components/modules listen for the ADD_TO_STAGE event and then have them register with the stage for the resize event. This ensures you have access to the stage before trying to add an event listener to it (otherwise it'll throw an error if you do it before the stage is available). It's also a good idea to listen for when components are removed from the stage and have them remove their own stage event listeners for good clean-up.
« Last Edit: July 06, 2009, 08:26:46 by Jason MacDonald » Logged
hesten
Sr. Member
****
Posts: 52


View Profile Email
« Reply #4 on: July 06, 2009, 11:54:11 »

Thank you very much Jason
Logged
Pages: [1]
Print