Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
May 25, 2017, 10:37:08 PM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1]
Print
Author Topic: Distributing Flash Vars to Various Proxies  (Read 3180 times)
caista
Newbie
*
Posts: 5


View Profile Email
« on: February 24, 2012, 04:34:05 AM »

Hi

I am loading in a large number of Flash Vars. I then want to distribute groups of them to different Proxies depending on their type.

At the moment I have a LoadFlashVarsCommand, which I envisage will register the various proxies and pass in the Flash vars. But Iīm not sure how to do this best.

Should LoadFlashVarsCommand, simply register all the Proxies, passing the "loaderInfo.parameters" object to each (in their constructors) and leaving each Proxy to parse that object themselves, picking out whichever variables are relevant?

If I do it this way, by using "super ( NAME, flashVars )" in the constructor, there will be a stored reference to the "loaderInfo.parameters" object in every Proxy. This seems a little untidy.

Alternatively, I could create various VOs in the LoadFlashVarsCommand, parse the data there, and then pass the relevant VOs containing only the relevant data to the right Proxies (again in their constructor).

If I do it this way, am I breaking the rules of PureMVC? Should Commands be parsing data and creating VOs?

Any general guidance would be greatly appreciated.

Thanks in advance!

caista
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2866



View Profile WWW
« Reply #1 on: February 24, 2012, 07:33:25 AM »

Here is a link to another post on this forum where I describe setting up a ParamsProxy, which exposes the FlashVars to the rest of the application like any other data.

Setting up a ParamsProxy
http://forums.puremvc.org/index.php?topic=622.msg2781#msg2781

Now if you want your other Proxies to have access to that data, the best thing to do is have them form a relationship with the ParamsProxy. While a Proxy can retrieve another Proxy, it's not the best way to go, since it is always possible you may register a Proxy that needs the ParamsProxy before the ParamsProxy has been registered. So make the ParamsProxy a constructor argument for Proxys that need to know the ParamsProxy:

Code:
public class SomeProxy extends Proxy
{
public static const NAME:String = "SomeProxy";
                private var paramsProxy:ParamsProxy;

/**
* Constructor.
*/
public function SomeProxy( paramsProxy:ParamsProxy )
{
      super ( NAME );
                        this.paramsProxy = paramsProxy
}

         }

-=Cliff>
« Last Edit: February 24, 2012, 07:34:58 AM by puremvc » Logged
caista
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: April 24, 2012, 06:19:25 AM »

Great, thanks Cliff, thatīs exactly what I did.
Logged
Pages: [1]
Print
Jump to: