MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Guida Utente Pagina 223

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 256
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 222
Build a distributed application with the ActionScript object adapter 223
Create variables
In this section, in the script block you declare variables for objects that you will use.
Directly below the import statements in the script block, add the following variable
declarations:
public var noteObj:Object = new Object();
public var getToken:AsyncToken;
private var ds:DataService;
[Bindable]
public var noteProxy:ObjectProxy;
Initialize the application
In this section, you write an event listener method that creates a DataService component and
calls the DataService component’s
getItem() method, which retrieves the current note text.
1. Add the following method declaration directly under the variable declarations to create an
event listener:
public function initApp():void {
}
2.
Add the boldface text to the initApp() method to create a DataService component when
the
initApp() method is called. The ds DataService component connects to the server-
side
notes Data Management Service destination, which is specified in its one argument.
public function initApp():void {
ds = new DataService("notes");
}
3.
Add the boldface text to the initApp() method. This code adds a Result event listener to
the DataService component and sets initial values for the noteObj object’s
noteId and
noteText properties. It also sets the value of the getToken object to the AsyncToken object
that the DataService component’s
getItem() method returns.
The ActionScript object adapter uses the
noteId property as a unique identifier for each
noteObj object, and the
noteText property contains the note text.
public function initApp():void {
ds = new DataService("notes");
ds.addEventListener(ResultEvent.RESULT, resultHandler);
ds.autoCommit = false;
noteObj.noteId = 1;
noteObj.noteText = "Type your notes here and share them with other
clients!";
getToken = ds.getItem(noteObj, noteObj);
}
Vedere la pagina 222
1 2 ... 218 219 220 221 222 223 224 225 226 227 228 ... 255 256

Commenti su questo manuale

Nessun commento