Fetching data from the server

Use the SyncManager fetch method to fetch data from the ColdFusion server by calling the fetch method of the server data object. The syncManager.fetch method takes the name of the CFC fetch method (typically fetch) as its first parameter, followed by any CFC fetch method parameters.

The syncManager.fetch method returns an AsyncToken object that provides access to the data. The function returns the token synchronously. The ColdFusion CFC response returns asynchronously. Therefore, call the token's addResponder method to specify a responder that handles the responses for successful and failed fetches.

To fetch the initial data from the server, you can include the following code in the Application init() method.

// fetch the data. 
var token:AsyncToken = syncmanager.fetch("fetch"); 
//Specify the responder to handle the fetch results. 
token.addResponder(new mx.rpc.Responder(fetchSuccess, fetchFault));