(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必须要在你的系统中实例化,具体的实例化方法如下:
2 ...
3 < control:ShopController id ="controller" />
4 ...
5 </ mx:Application >
提供了HTTPService、WebSercice、RemoteObject三种RPC服务。使用时候,将需要的RPC服务登记在该接口中,
以mxml形式采用单例模式(Singleton Pattern)实现IServiceLocator,如下面使用例子:
2 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 >
2 ...
3 < business:Services id ="services" />
4 ...
5 </ mx:Application >
学习Cairngorm站点、文章收集.
1:http://www.davidtucker.net/category/cairngorm/ 入门强烈推荐
*http://www.cairngormdocs.org/tools/CairngormDiagramExplorer.swf cairngorm图解法表示
http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm 推荐
2:http://opensource.adobe.com/wiki/display/cairngorm/Developer+Documentation
3:http://www.adobe.com/devnet/flex/articles/graduating_pt1.html
4:http://www.adobe.com/devnet/flex/articles/cairngorm_pt1.html
5:http://jessewarden.com/2007/08/10-tips-for-working-with-cairngorm.html
6:Cairngorm学习——使用WebService和HTTPService服务
7:AIR也可以Cairngorm -- http://www.ericfeminella.com/blog/2007/07/16/air-cairngorm-air-extensions-for-cairngorm/
实例:http://www.duzengqiang.com/blog/article.asp?id=198 Flex Example: HTTPService & Cairngorm 2.2