PureMVC学习(二)
来源:互联网 发布:卤汁豆腐干淘宝 编辑:程序博客网 时间:2024/05/21 17:02
Command与Mediator和Proxy交互,应避免Mediator与Proxy直接交互。看下面一个用于程序"启动"的Command:
package com.wf.controller{import org.puremvc.as3.core.Model;import org.puremvc.as3.patterns.command.MacroCommand;/** * 程序开始时执行的MacroCommand */ public class StartupCommand extends MacroCommand{/** * 添加子Command初始化MacroCommand */ override protected function initializeMacroCommand():void{addSubCommand(ModelPrepCommmand);addSubCommand(ViewPrepCommand);}}}
这是一个添加了两个子Command的MacroCommand.执行时,两个子命令会按照FIFO的顺序被执行。
一般,开启(startup)主要有两个过程:Model初始化与View初始化。
package com.wf.controller{import org.puremvc.as3.interfaces.INotification;import org.puremvc.as3.patterns.command.SimpleCommand;//创建Proxy对象,并注册public class ModelPrepCommand extends SimpleCommand{//由MacroConmmand调用override public function execute(notification:INotification):void{facade.registerProxy(new SearchProxy());facade.registerProxy(new PrefsProxy());facade.registerProxy(new UserProxy());}}}
Command并没有操作或初始化任何的Model数据.Proxy的职责才是取得、创建 和初始化数据对象。
package com.wf.controller{import mx.core.Application;import org.puremvc.as3.interfaces.INotification;import org.puremvc.as3.patterns.command.SimpleCommand;//创建Mediator,并把他们注册到Viewpublic class ViewPrepCommand extends SimpleCommand{override public function execute(notification:INotification):void{var app:PureMvcStudy = notification.getBody() as PureMvcStudy;facade.registerMediator(new ApplicationMediator(app));}}}
- PureMVC学习(二)
- puremvc学习笔记
- PureMVC学习教程
- pureMVC 学习资料
- PureMvc学习(一)
- Flex PureMVC 学习
- pureMVC 学习笔记
- iOS- PureMVC 学习
- puremvc
- pureMVC
- pureMVC
- puremvc
- pureMVC
- PureMVC
- PureMVC
- 学习使用PureMVC一周,感受
- PureMVC 学习(吐槽)笔记
- PureMVC学习笔记之基础概念
- ATL入门:利用ATL编写简单的COM组件
- 态度觉得一切
- svn 命令行操作的文件名中包含@ 时的转义方式
- PHP与UML类图: PHP and UML Class Diagram
- opencv c++函数 highgui模块 1 为程序界面添加滑动条
- PureMVC学习(二)
- 如何查看linux 版本,32位还是64位
- shell中if做比较
- 判断点在线段的左右侧
- 【mysql】开启慢查询日志
- 用javascript编写优美的代码新手晋级
- 算法导论 2.1-3
- hdu1527
- android设置dialog显示和activity进入退出的动画效果