
232 Use the Data Management Service
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 and an
ArrayCollection object when the
initApp() method is called.
The
ds DataService connects to the server-side contact Data Management Service
destination, which is specified in its one argument.
public function initApp():void {
contacts = new ArrayCollection();
ds = new DataService("contact");
}
3.
Add the boldface text to the initApp() method to call the DataService object’s fill()
method when the
initApp() method is called.
The
fill() method requests data from the server-side Data Management Service
destination and fills the contacts ArrayCollection with that data. The DataService object
manages all updates, additions, and deletions to the data in the ArrayCollection.
public function initApp():void {
contacts = new ArrayCollection();
ds = new DataService("contact");
ds.fill(contacts);
}
4.
Add the boldface text to the <mx:Application> tag to call the initApp() method when
the contact application is initialized:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp();">
Kommentare zu diesen Handbüchern