package com.me.myapp.model
{
import org.puremvc.as3.multicore.patterns.proxy.Proxy;
/**
* Parameters Proxy.
* <P>
* Maintains the parameters object that corresponds to
* the <code>FlashVars</code> passed into the Application
* via the OBJECT/EMBED tag in the HTML wrapper.</P>
*/
public class ParamsProxy extends Proxy
{
public static const NAME:String = "ParamsProxy";
/**
* Constructor.
*/
public function ParamsProxy( params:Object )
{
super ( NAME, params );
}
/**
* Get the vendorName parameter.
*/
public function get vendorName():String
{
return params.vendorName as String;
}
/**
* Get the appName parameter.
*/
public function get appName():String
{
return params.appName as String;
}
/**
* Get the appVersion parameter.
*/
public function get appVersion():String
{
return params.appVersion as String;
}
/**
* The parameters supplied to the main application.
* <P>
* There are two sources of parameters: the query
* string of the Application's URL, and the value
* of the FlashVars HTML parameter.</P>
*/
public function get params():Object
{
return data as Object;
}
}
}
///"In the StartupCommand, since I have a reference to the Application, and parameters is a direct public property, I just register a ParamsProxy at that time:"
package com.me.myapp
{
import com.me.myapp.MyApp;
import com.me.myapp.model.ParamsProxy;
import com.me.myapp.view.ApplicationMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
/**
* Startup.
*
* Creates and registers the initial Proxies and Mediators
*
* @param note the STARTUP notification
*/
public class StartupCommand extends SimpleCommand
{
override public function execute(note:INotification):void
{
// Retrieve the Application reference and register the ApplicationMediator
var myApp:MyApp = note.getBody() as MyApp;
// Register the ParamsProxy
// It maintains the FlashVars and initial QueryString parameters
facade.registerProxy( new ParamsProxy( myApp.parent.loaderInfo.parameters ) );
// Register the ApplicationMediator
facade.registerMediator( new ApplicationMediator( myApp ) );
}
}
}