

























1. MVC的核心思想
2. 模型 - 视图 - 控制器
3. PureMVC框架
在PureMVC实现的经典MVC元设计模式中,这三部分由三个单例模式类管理,分别是Model 、View和Controller。三者合称为核心层或核心角色。PureMVC中还有另外一个单例模式类——Façade,Façade提供了与核心层通信的唯一接口,以简化开发复杂度。

从设计图中可以清楚看到,除了核心层、Façade之外,还有Mediator、Proxy、Command。
4. PureMVC初始化流程
PureMVC框架的入口是继承Façade的子类:ApplicationFacade。startUp()方法启动初始化框架。
ApplicationFacade类:
public class ApplicationFacade extends Facade implements IFacade
{
private static const STARTUP:String = "startup";
public static function getInstance():ApplicationFacade
{
if (instance == null)
instance = new ApplicationFacade();
return instance as ApplicationFacade;
}
override protected function initializeController():void
{
super.initializeController();
registerCommand(STARTUP, StartupCommand);
}
public function startUp(rootView:DisplayObjectContainer):void
{
sendNotification(STARTUP, rootView);
removeCommand(STARTUP); //PureMVC初始化完成,注销STARUP命令
}
}
调用startUp()启动应用程序,发送STARTUP命令;然后触发StartupCommand,它包含三个子command执行(这里借鉴Robotlegs的思想,将Command、Model、ViewMediator初始化工作分离,使得程序结构更清晰。)
简而言之,框架初始化流程可以表示如下:
5. PureMVC模块间通信
当一个模块需要与其它模块交互时,可以通过发送/接收Notification或者通过façade的facade.retrieveMediator、facade.retrieveProxy检索到指定模块,然后调用相应接口。
引自:http://www.cnblogs.com/skynet/category/441705.html
参考:http://www.cnblogs.com/QLeelulu/category/123326.html
http://www.cnblogs.com/iamlilinfeng/category/454097.html
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。