ActionScript 3 用于PureMVC的ParamsProxy

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 用于PureMVC的ParamsProxy相关的知识,希望对你有一定的参考价值。

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 ) );

		}
		
	}
}

以上是关于ActionScript 3 用于PureMVC的ParamsProxy的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 PureMVC的BulkLoader代理

ActionScript 3 PureMVC中的PopUpManager

ActionScript 3 PureMVC文档类模板

什么 IDE 可用于 ActionScript 3 编码? [关闭]

ActionScript 3 用于管理DisplayObject的深度

基于Pipe的PureMVC FLEX框架的多核共享消息技术