<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PawaStation 能猫环岛 &#187; flex</title>
	<atom:link href="http://blog.pawa.ca/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pawa.ca</link>
	<description>An Apple a Day Keeps the Doctor Away</description>
	<lastBuildDate>Sun, 08 Mar 2009 04:39:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Cairngorm In One File</title>
		<link>http://blog.pawa.ca/2007/10/18/cairngorm-in-one-file/</link>
		<comments>http://blog.pawa.ca/2007/10/18/cairngorm-in-one-file/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 06:08:24 +0000</pubDate>
		<dc:creator>pawaca</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[caringorm]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.pawa.ca/?p=51</guid>
		<description><![CDATA[最近有机会研究了一下传说中的 Cairngorm 框架，整体感觉还不错，其中的模块化概念可以使项目在变大变复杂之后依然可控。 具体优点就不说了，说说最大的缺点，就是 繁琐 。由于要分离用户触发事件以及对应的 Command 操作，导致几乎每个明显的用户操作都要写一个 Event 类（还真是累阿）；另外由于 Cairngorm 本身是一个 design patten 的实践，不是 library，所以造成实际使用的时候需要死版的 implement 一些不着调的空 interface。 简单来说 Cairngorm 是一个婆婆妈妈的 framework，这从技术上来说也不是什么问题，但是重点是会影响写代码人的心情。比如我，一想到要每一个 action 都要写一个没什么特别之处的 Event class 就觉得头疼，一头疼就不想干，一不想干就完了。。。 所以，我就想能不能保留 Cairngorm 的思想，但是用一种更简洁的方式来实现？最后不小心想出了一招，经过一段时间的实验，感觉效果还不错，和大家分享一蛤。 global.as 我把 Cairngorm 的思想融入到一个名叫 global 的类中，使用的时候只需要这一个文件就包含了全部 Cairngorm 相关内容。我打算用一个通过 webservices 查询当前货币兑换比例的例子来具体的说一下 Cairngorm 各方面的特性，以及如何用 global 来实现这些特性。 全局的数据管理 Cairngorm 通过一个 singleton 的 ModelLocator 来连接数据与用户界面，基本思路是全部 ui 相关的数据都不是直接设置到组件上，而是通过一个全局的对象借由 binding [...]]]></description>
			<content:encoded><![CDATA[<p>最近有机会研究了一下传说中的 Cairngorm 框架，整体感觉还不错，其中的模块化概念可以使项目在变大变复杂之后依然可控。</p>

<p>具体优点就不说了，说说最大的缺点，就是 繁琐 。由于要分离用户触发事件以及对应的 Command 操作，导致几乎每个明显的用户操作都要写一个 Event 类（还真是累阿）；另外由于 Cairngorm 本身是一个 design patten 的实践，不是 library，所以造成实际使用的时候需要死版的 implement 一些不着调的空 interface。</p>

<p>简单来说 Cairngorm 是一个婆婆妈妈的 framework，这从技术上来说也不是什么问题，但是重点是会影响写代码人的心情。比如我，一想到要每一个 action 都要写一个没什么特别之处的 Event class 就觉得头疼，一头疼就不想干，一不想干就完了。。。</p>

<p>所以，我就想能不能保留 Cairngorm 的思想，但是用一种更简洁的方式来实现？最后不小心想出了一招，经过一段时间的实验，感觉效果还不错，和大家分享一蛤。</p>

<h3>global.as</h3>

<p>我把 Cairngorm 的思想融入到一个名叫 global 的类中，使用的时候只需要这一个文件就包含了全部 Cairngorm 相关内容。我打算用一个通过 webservices 查询当前货币兑换比例的例子来具体的说一下 Cairngorm 各方面的特性，以及如何用 global 来实现这些特性。</p>

<p><img src="http://blog.pawa.ca/wp-content/uploads/2009/03/global_test.png" alt="" height="80" width="429" /></p>

<h3>全局的数据管理</h3>

<p>Cairngorm 通过一个 singleton 的 ModelLocator 来连接数据与用户界面，基本思路是全部 ui 相关的数据都不是直接设置到组件上，而是通过一个全局的对象借由 binding 来实现。这样做分离了组件、数据以及命令之间的依靠。当有某个命令修改了某一个数据源之后，不用主动的再去更新组件显示，所有已经设置对应 binding 的组件将会自动更新。</p>

<p>global.as 将自身作为 ModelLocator 来使用，相关代码如下：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// bindable properties, access from global.data model locator.</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> fromCurrency<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>=“USD”<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> toCurrency<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>=“CNY”<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> currencyResult<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>=“”<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> state<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>=STATE_LOAD<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">enabled</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=boolean%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:boolean.html"><span style="color: #004993;">Boolean</span></a>=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #3f5fbf;">/**<br />
&nbsp;* The global singleton model locator.<br />
&nbsp;*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">global</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _data<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>

<p>然后在对应需要响应数据更新的组件上通过绑定 global.data 中的对应属性来实现更新。比如实例中用来显示货币兑换比例结果的 Label 组件绑定了 global.data.currencyResult 属性。</p>

<div class="codecolorer-container mxml mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="mxml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;{global.data.currencyResult}&quot;</span> color=<span style="color: #ff0000;">&quot;0x00ff00&quot;</span><span style="color: #7400FF;">&gt;</span><span style="color: #7400FF;">&lt;/mx:label</span><span style="color: #7400FF;">&gt;</span></span></div></td></tr></tbody></table></div>

<h3>全局的事件播报以及响应</h3>

<p>在 Cairngorm 中，程序通过全局的 EventDispatcher 来播报全部程序相关的事件，然后对应处理事件的 Command 则通过 FrontController 在程序初始阶段配置好与对应事件的监听关系。副作用是：随着程序复杂程度的增加，会出现一堆只是名字不同的 Event class，以及只为了 execute 一下下却不得不实现的 ICommand 类。</p>

<p>global.as 通过静态方法 fire/listen/unlisten 实现了全局的事件播报以及监听功能，其中为了避免过多 Event class 的出现，fire 方法会播报出 DynamicEvent，并允许设置任意参数到 event 对象上，在实例中当用户点击了 Calculate Conversion Rate 按钮后会这样触发事件</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;global.fire(global.EVENT_CONVERSION_RATE,{fromCurrency:fromField.text,toCurrency:toField.text})&quot;</span></div></td></tr></tbody></table></div>

<p>另一方面 command 响应事件，也做了相应的简化：直接用 function 作为 command 来进行实际的业务操作：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> conversionRate<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span>DynamicEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//..</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> fromCurrency<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>=<a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span>fromCurrency<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> toCurrency<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a>=<a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span>toCurrency<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//..</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>

<p>最后在程序初始化的时候将 command 和对应的事件建立联系（类似 Cairngorm 中 FrontController 的功能）</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339966; font-weight: bold;">function</span> registerDefaultCommands<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//register default commands here.</span><br />
&nbsp; &nbsp; <span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>listen<span style="color: #000000;">&#40;</span><span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>EVENT_LOAD_WSDL<span style="color: #000066; font-weight: bold;">,</span>loadWsdl<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>listen<span style="color: #000000;">&#40;</span><span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>EVENT_CONVERSION_RATE<span style="color: #000066; font-weight: bold;">,</span>conversionRate<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>

<h3>全局的网络服务资源</h3>

<p>最后关于远程 service 的部分，Cairngorm 提供了另外一个 singleton 的 ServiceLocator 供程序使用，并通过 Responder 来响应服务返回的结果。</p>

<p>在 global.as 中通过一个 rpc 方法实现了注册以及使用 service 的功能。比如实例中 webservices 的注册如下：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339966; font-weight: bold;">function</span> registerDefaultServices<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//register default services here.</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> s<span style="color: #000066; font-weight: bold;">:</span>WebService=<span style="color: #0033ff; font-weight: bold;">new</span> WebService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//..</span><br />
&nbsp; &nbsp; <span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>rpc<span style="color: #000000;">&#40;</span><span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>CONVERSION_DESTINATION<span style="color: #000066; font-weight: bold;">,</span>s<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>

<p>然后代码通过以下方法访问上面注册的 service：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> currencyConvertor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:*</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> rpc<span style="color: #000000;">&#40;</span>CONVERSION_DESTINATION<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>

<p>实际上 rpc 方法返回的是一个 service 的 proxy 对象。和直接使用 service 不同的是，通过 proxy 简化了服务方法调用后结果响应部分的代码。比如实例中获取货币兑换比率的方法是这样写的：</p>

<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span>currencyConvertor<span style="color: #000066; font-weight: bold;">.</span>ConversionRate<span style="color: #000000;">&#40;</span>fromCurrency<span style="color: #000066; font-weight: bold;">,</span>toCurrency<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>currencyResult=<span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span>result<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>fault<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">message</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">info</span><span style="color: #000066; font-weight: bold;">.</span>fault<span style="color: #000066; font-weight: bold;">.</span>faultString<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>o<span style="color: #000066; font-weight: bold;">:*</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">global</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">enabled</span>=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>

<p>其中第一个函数处理成功，第二个函数处理失败，第三个函数无论成功失败都会先执行。</p>

<p>至此 Cairngorm 的全部功能都被 global.as 实现了。如果有盆友对我瞎掰的这些感兴趣，可以 <a href="http://blog.pawa.ca/wp-content/uploads/2009/03/global_test.zip">下载 sample source</a> 然后把你的想法告诉我。</p>

<p>Over <img src='http://blog.pawa.ca/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.pawa.ca/2007/10/18/cairngorm-in-one-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlexSpy</title>
		<link>http://blog.pawa.ca/2004/08/12/flexspy/</link>
		<comments>http://blog.pawa.ca/2004/08/12/flexspy/#comments</comments>
		<pubDate>Thu, 12 Aug 2004 04:23:15 +0000</pubDate>
		<dc:creator>pawaca</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.pawa.ca/?p=77</guid>
		<description><![CDATA[昨天写了个小东西，FlexSpy(灵感来自于 SWT Spy )。它可以用来侦测任意鼠标下的MovieClip和TextField。这个工具可以帮助你更深入的了解V2Component的内部构成。 用法很简单： 1pawaca.debug.FlexSpy.monitoring=true; 这里 下载FlexSpy]]></description>
			<content:encoded><![CDATA[<p>昨天写了个小东西，FlexSpy(灵感来自于 <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-swt-home/dev.html#tools"><span class="caps">SWT</span> Spy</a> )。它可以用来侦测任意鼠标下的MovieClip和TextField。这个工具可以帮助你更深入的了解V2Component的内部构成。</p>

<p><img src="http://blog.pawa.ca/wp-content/uploads/2009/03/flexspy_dem.png" alt="" height="131" width="383" /></p>

<p>用法很简单：</p>

<div class="codecolorer-container actionscript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">pawaca.<span style="color: #006600;">debug</span>.<span style="color: #006600;">FlexSpy</span>.<span style="color: #006600;">monitoring</span>=<span style="color: #000000; font-weight: bold;">true</span>;</div></td></tr></tbody></table></div>

<p>这里 <a href="http://blog.pawa.ca/wp-content/uploads/2009/03/flexspy.rar">下载FlexSpy</a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.pawa.ca/2004/08/12/flexspy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
