PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: remida on March 30, 2009, 01:52:24



Title: Passing stage size to components
Post by: remida 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.


Title: Re: Passing stage size to components
Post by: puremvc 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>