Flex中PureMVC 学习小结
2009-03-18 12:00:20 来源:WEB开发网导入ApplicationFacade类. 声明一个函数为intApp()并在页面加载完成后执行:craationComplete = "intApp()";
声明了一个变量facade,类型是ApplicationFacade,并执行start(),这样程序就启动了..
第四步:
startCommand:
在ApplicationFacade中,我声明了AppConstance.START,这个通知与startCommand的映射,即,在程序开始执行时,就需要去执行startCommand
代码:
package myApp.Controller
{
import myApp.AppConstance;
import myApp.Model.userProxy;
import myApp.View.chooseMediator;
import myApp.View.loginMediator;
import org.puremvc.as3.interfaces.ICommand;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.SimpleCommand;
public class startCommand extends SimpleCommand implements ICommand
{
public function startCommand()
{
super();
}
override public function execute(notification:INotification):void
{
var body:Object = notification.getBody();
var type:String = notification.getType();
if(type == "myweb"){
this.facade.registerCommand(AppConstance.LOGIN,loginCommand);
this.facade.registerMediator(new chooseMediator(body));
this.facade.registerMediator(new loginMediator(body));
this.facade.registerProxy(new userProxy());
this.sendNotification(AppConstance.TO_CHOOSE,body)
}else{
trace("不是本站");
}
}
}
}
更多精彩
赞助商链接