用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: 正在从服务器检索数据...
正在从服务器检索数据...
com.adobe.gravity.utility.async 

IToken  - AS3 ADEP Client Component

com.adobe.gravity.utility.async
接口public interface IToken
实现器 AggregatingToken, AsyncTokenWrapper, ImmediateFaultToken, ImmediateSuccessToken, Token

语言版本: ActionScript 3.0
产品版本: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
运行时版本: AIR 1.1, Flash Player 9

IToken objects are returned from functions that initiate asynchronous operations. You are guaranteed that either the fault handlers or the success handlers will be invoked, depending on whether the operation succeeded or failed.

Success handlers take an arbitrary number of parameters. The number and type of the parameters depend on the API that returns the token; the API documentation will generally indicate what to expect. Fault handlers must take a single parameter of type Error.

The asynchronous token concept: the classes in this package implement the asynchronous token concept. Instead of calling asynchronous methods on an object and adding event listeners to that object to learn the result, a token is returned from the asynchronous method and success and fault handlers are added to the token.

For example, in the traditional Flash model one might have:

	 public function addPhotoToLibrary(photoUrl:String, library:PhotoLibrary):void
	 {
	    library.importPhoto(photoUrl);
	    library.addEventHandler(PhotoLibraryEvent.IMPORT_COMPLETE, importCompleteHandler);
	    library.addEventHandler(PhotoLibraryEvent.IMPORT_FAULT, importFaultHandler);
	 }
	 
	 public function importCompleteHandler(event:PhotoLibraryEvent):void
	 {
	    library.removeEventHandler(PhotoLibraryEvent.IMPORT_COMPLETE, importCompleteHandler);
	    library.removeEventHandler(PhotoLibraryEvent.IMPORT_FAULT, importFaultHandler);
	    var photo:IPhoto = event.photo;
	    // now that the photo has been imported, do something else
	 }
	 	
	 public function importFaultHandler(fault:FaultEvent):void
	 {
	 library.removeEventHandler(PhotoLibraryEvent.IMPORT_COMPLETE, importCompleteHandler);
	 library.removeEventHandler(PhotoLibraryEvent.IMPORT_FAULT, importFaultHandler);
	 // deal with the error here
	 }
	 

With a token, the pattern is slightly different:

	 public function addPhotoToLibrary(photoUrl:String, library:PhotoLibrary):void
	 {
	    var token:IToken = library.importPhoto(photoUrl);
	    token.addSuccessHandler(importCompleteHandler);
	    token.addFaultHandler(importFaultHandler);
	 }
	 
	 public function importCompleteHandler(photo:IPhoto):void
	 {
	    // now that the photo has been imported, do something else
	 }
	 
	 public function importFaultHandler(error:Error):void
	 {
	 // deal with the error here
	 }
	 

The benefit of this model is that since the token is associated with a specific invocation of the operation, handlers added to that token will only get invoked for that specific operation invocation.



公共方法
 方法由以下参数定义
  
addFaultHandler(handler:Function, weakReference:Boolean = false):void
Add a handler to be called if the operation fails.
IToken
  
addSuccessHandler(handler:Function, weakReference:Boolean = false):void
Add a handler to be called if the operation succeeds.
IToken
  
Remove a fault handler.
IToken
  
Remove a success handler.
IToken
方法详细信息

addFaultHandler

()方法
public function addFaultHandler(handler:Function, weakReference:Boolean = false):void

语言版本: ActionScript 3.0
产品版本: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
运行时版本: AIR 1.1, Flash Player 9

Add a handler to be called if the operation fails.

参数

handler:Function — A function to be called if the operation fails.
 
weakReference:Boolean (default = false) — Use a weak reference to hold onto the handler.

addSuccessHandler

()方法 
public function addSuccessHandler(handler:Function, weakReference:Boolean = false):void

语言版本: ActionScript 3.0
产品版本: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
运行时版本: AIR 1.1, Flash Player 9

Add a handler to be called if the operation succeeds.

参数

handler:Function — A function to be called if the operation succeeds.
 
weakReference:Boolean (default = false) — Use a weak reference to hold onto the handler.

removeFaultHandler

()方法 
public function removeFaultHandler(handler:Function):void

语言版本: ActionScript 3.0
产品版本: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
运行时版本: AIR 1.1, Flash Player 9

Remove a fault handler.

参数

handler:Function — The handler to be removed.

removeSuccessHandler

()方法 
public function removeSuccessHandler(handler:Function):void

语言版本: ActionScript 3.0
产品版本: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
运行时版本: AIR 1.1, Flash Player 9

Remove a success handler.

参数

handler:Function — The handler to remove.





[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。