ActionScript® 3.0 — dokumentacja dla platformy Adobe® Flash®
Strona główna  |  Ukryj listę pakietów i klas |  Pakiety  |  Klasy  |  Nowości  |  Indeks  |  Dodatki  |  Dlaczego język angielski?
Filtry: Pobieranie danych z serwera...
Pobieranie danych z serwera...
com.adobe.gravity.utility.async 

IToken  - AS3 ADEP Client Component

Pakietcom.adobe.gravity.utility.async
Interfejspublic interface IToken
Implementory AggregatingToken, AsyncTokenWrapper, ImmediateFaultToken, ImmediateSuccessToken, Token

Wersja języka: ActionScript 3.0
Wersja produktu: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Wersje środowiska wykonawczego: 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.



Metody publiczne
 MetodaZdefiniowane przez
  
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
Szczegół metody

addFaultHandler

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

Wersja języka: ActionScript 3.0
Wersja produktu: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Wersje środowiska wykonawczego: AIR 1.1, Flash Player 9

Add a handler to be called if the operation fails.

Parametry

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

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

Wersja języka: ActionScript 3.0
Wersja produktu: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Wersje środowiska wykonawczego: AIR 1.1, Flash Player 9

Add a handler to be called if the operation succeeds.

Parametry

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

()metoda 
public function removeFaultHandler(handler:Function):void

Wersja języka: ActionScript 3.0
Wersja produktu: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Wersje środowiska wykonawczego: AIR 1.1, Flash Player 9

Remove a fault handler.

Parametry

handler:Function — The handler to be removed.

removeSuccessHandler

()metoda 
public function removeSuccessHandler(handler:Function):void

Wersja języka: ActionScript 3.0
Wersja produktu: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Wersje środowiska wykonawczego: AIR 1.1, Flash Player 9

Remove a success handler.

Parametry

handler:Function — The handler to remove.





[ X ]Dlaczego język angielski?
Treść dokumentacji języka ActionScript 3.0 wyświetlana w języku angielskim

Niektóre części dokumentacji języka ActionScript 3.0 nie są przetłumaczone na poszczególne języki. Gdy element nie jest przetłumaczony na dany język, jest wyświetlany tekst angielski. Na przykład opis klasy ga.controls.HelpBox nie jest przetłumaczony na żaden dodatkowy język. Z tego powodu polska wersja dokumentacji zawiera opis klasy ga.controls.HelpBox w języku angielskim.