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: Where do I keep a reference to my Stage?  (Read 9159 times)
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« on: March 23, 2009, 03:07:00 »

I need to use the Stage size in two of my views and I was wondering where is the right place to put that information to be used later during the application.

Suggestions?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 23, 2009, 03:21:24 »

Create a StageMediator. If it needs to be queried for size you can retrieve it and invoke a method on it to get this info.

I believe the HelloFlash demo implements a StageMediator, as does the DesktopCitizen utiloty which is used by the CodePeek and RSSReader demos.

-=Cliff>
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #2 on: March 23, 2009, 03:30:24 »

Hi,

Thanks for the response, I was looking at the board and found this topic:

http://forums.puremvc.org/index.php?topic=812.0

Which is similar to what I am doing but in that case it is suggested to "save" the information in a Proxi. Which would be more valuable? Using a Proxi or a Mediator? My logic tells me that the Mediator should be the way to go but I am curios how the other post took the Proxi route.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: March 23, 2009, 04:03:59 »

It all depends on when,where and why you need the info. My suggestion above allows you to get at it dynamically. And 99 percent of the time you'll want to do things this way. Why make a model class that reflects dynamic properties of the view? The Model is for data about the domain, not the View. the view component (stage, button or whatever) is in charge of holding its properties, so query it (through a mediator) if you need to know its properties.

The only time you'd want to store these properties in a Proxy is if you will be persisting them (in which case those properties are now actually part of the domain).

To see an example, check out the CodePeek and RssReader demos which use the DesktopCitizen utility. This AIR utility persists the window metrics to disk so that when you launch your AIR app it rememebers its desktop position, window size and whether it was maximized.

-=Cliff>
Logged
Helmut Granda
Full Member
***
Posts: 47

Flash Developer.


View Profile WWW Email
« Reply #4 on: March 23, 2009, 05:48:50 »

Interesting! I was talking about this with a coworker and we were discussing 2 options.

1 would be to pass a reference of the stage during the Mediator instantiation giving us the flexibility in the future to change targets ( where the object is being created, say we want to use a sprite or movieclip in the future)

2 get the target object dynamcally as you explained earlier, which I like best but see the issue of maybe not being as flexible because we have to hard-code the target.

Either way it will be hardcoded and I guess I might be just over thinkng it. What do you think?

I will look at the samples you mentioned.
Logged
Pages: [1]
Print