Flex是一个面向服务的框架, 借用了异步完成标记(Asynchronous Completion Token)设计模式, 代码以异步的方式运行.
此模式将用户的操作完成信号以及数据以异步的方式返回给用户,
这种做法的效率比较高, 用户不需要同步等待运行结果. 可以在服务运行的同时进行其他操作.
使用ACT模式时, 需要将服务返回的动作和数据绑定到一个异步的处理操作.
ACT必须在服务调用前进行指定. 服务调用时,用户可以进行其他操作, 当服务结束, 用户使用ACT接收响应并进行相应的处理.
当调用HTTP Service, RemoteObject, WebService时, Flex会返回一个数据服务调用(Data Service Call)的实例.
你可以使用 webService.send()返回的调用对象(Call Object)来进行结果处理. 你可以在调用对象中添加信息,
并在结果事件的处理函数中通过event.call得到调用对象.这就是ACT的实现机制. 代码举例如下:


<mx:HTTPService id="MyService" url="
" result="myHandler(event)" />


<mx:Script>
<

function storeCall()


{
// Create a variable called call to store the instance
// of the service call that is returned.
var call = MyService.send();
// Add a variable to the call object that is returned.
// You can name this variable whatever you want.
call.marker = "option1";


}
// In a result event handler, execute conditional
// logic based on the value of call.marker.
function myHandler(event)


{
var call = event.call

if (call.marker == "option1")
{
//do option 1
}
else


}
]]>
</mx:Script>在调用服务(MyService.send())时, 返回了调用对象 call
可以给调用对象添加信息 call.marker = "option1";
在服务完成的处理函数中可以使用 event.call 获得调用对象, 从而获得信息(call.marker).