Flex框架 Robotlegs学习记录

最近在用FLEX4.5开发,学习了Robotlegs框架,记录一下

官方网站下载swc开发包:http://www.robotlegs.org/,下载解压之后找到BIN目录下的robotlegs-framework-v1.5.2.swc拷贝到项目的libs目录下

Robotlegs框架原理图:

 

 

大体流程:

AppContext类继承Context类,重写父类的startup()方法:

this.mediatorMap.mapView(UserLogin, UserLoginMediator);

//映射登录mediator,映射之后,UserLogin.mxml组件和UserLoginMediator则绑定在一起了,UserLoginMediator继承Mediator,可重写父类的onRegister()方法通过

this.eventMap.mapListener(userLogin.loginBtn, MouseEvent.CLICK, startUserLogin);

增加对UserLogin.mxml组件的loginBtn按钮的单击事件监听,startUserLogin方法则会通过

dispatch(new UserEvent(UserEvent.LOGIN, u));

派发一个UserEvent.LOGIN的用户自定义LOGIN事件。

 

this.commandMap.mapEvent(UserEvent.LOGIN, LoginCommand, UserEvent, false);

//通过这句话则告诉LoginCommand让它响应事件,LoginCommand继承Command,可重写父类的execute()方法里面响应事件,这里用到了Inject把

[Inject]

public var event:UserEvent;

用户自定义事件UserEvent注入到LoginCommand类,然后在execute()方法里通过event获得当前的对象,进行业务逻辑处理(可以把Model类也注入进来进行数据模型的一些处理),处理完之后,派发一个自定义事件UserEvent.LOGIN_SUCCESS。

如果UserLoginMediator类里的OnRegister()方法有这句话:

this.addContextListener(UserEvent.LOGIN_SUCCESS, successLogin);

则UserLoginMediator会响应这个自定义事件,然后告诉用户登录成功失败等等。

 

this.injector.mapSingleton(UserLoginModel); //映射Model类

this.injector.mapSingleton(AppService); //映射Service类(可注入到Meditor)

 

 

转载于:https://www.cnblogs.com/slack/archive/2012/07/06/As.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值