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: Passing stage size to components  (Read 6018 times)
remida
Newbie
*
Posts: 5


View Profile Email
« on: March 30, 2009, 01:52:24 »

Hi there, I'm new in pureMVC so sorry if my question is a little bit stupid. I create some Mediators/Components and I want the sprites positions and sizes in the components are set before the component is added to the displayList (often positions and sizes depends on the stage size). Usally (not in pureMVC projects) I pass the stageWidth and the stageHeight or a reference to the stage to the component constructor. In pureMVC I'm not sure about what to do. Maybe I could retrieve the stage from the StageMediator (exposing the componentView) when I create mediator/component, but I'm not sure it's a "best practice": in this way I couple the new Mediator with StageMediator. Have you got any suggestion? Thanks in advance.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 30, 2009, 03:58:40 »

Rather than retrieving the stage itself from the StageMediator, expose a getter on the StageMediator that returns the Stage size. This way you keep the StageMediator as the only touchpoint for the Stage, but you are still able to get the information you need.

-=Cliff>
Logged
Pages: [1]
Print