Cairngorm学习——什么是Cairngorm?
2008-6-5 21:09:00
(1)CairngormEvent:
继承flash.events.Event,其包含一个data成员,用来传递参数数据之用。
(2)CairngormEventDispatcher:
采用单例模式(Singleton Pattern),用来广播用户发起的自定义动作事件。
(3)FrontController:
相当于控制中心,在这里你要做的工作是将事件(CairngormEvent)和命令(Command)之间的映射关系注册在它的
成员commands(Dictionary类型)中,通过下面的类似方法进行注册:
addCommand( GetProductsEvent.EVENT_GET_PRODUCTS, GetProductsCommand );
以后,凡是CairngormEventDispatcher广播出来的事件,首先都会在这里查找,找到对应的event对应的command后,
便执行Command的execute()方法。
FrontController必须要在你的系统中实例化,具体的实例化方法如下:
<
mx:Application
xmlns:control
="com.domain.projectname.control.ShopController"
>
2
...3
<
control:ShopController
id
="controller"
/>
4
...5
</
mx:Application
>
提供了HTTPService、WebSercice、RemoteObject三种RPC服务。使用时候,将需要的RPC服务登记在该接口中,
以mxml形式采用单例模式(Singleton Pattern)实现IServiceLocator,如下面使用例子:
<
cairngorm:ServiceLocator2
xmlns:mx
="http://www.adobe.com/2006/mxml"
3
xmlns:cairngorm
="http://www.adobe.com/2006/cairngorm"
>
4

5
<
mx:RemoteObject
id
="productService"
destination
="productServiceImpl"
showBusyCursor
="true"
>
6
</
mx:RemoteObject
>
7

8
<
mx:RemoteObject
id
="creditCardService"
destination
="creditCardServiceImpl"
showBusyCursor
="true"
>
9
</
mx:RemoteObject
>
10

11
<
mx:HTTPService
id
="XXXService"
url
="URL"
showBusyCursor
="true"
useProxy
="false"
resultFormat
="e4x"
>
12
</
mx:HTTPService
>
13

14
</
cairngorm:ServiceLocator
>
<
mx:Application
xmlns:business
="com.adobe.cairngorm.samples.store.business.*"
>
2
...3
<
business:Services
id
="services"
/>
4
...5
</
mx:Application
>
this.service = ServiceLocator.getInstance().getRemoteObject( "productService" );

1395

被折叠的 条评论
为什么被折叠?



