About working with RecordSet objects
79
To set up a notification event for an ActionScript object, use the RecordSet
addEventListener()
method and specify the object to notify when the RecordSet object
changes. You can specify any object that receives change notifications in the
addEventListener()
method, as in the following example:
myRecordSet.addEventListener("modelChanged", contact_grid);
In this example, the myRecordSet object represents a record set returned from Flash Remoting,
and the
addEventListener()
method tells Flash Remoting to notify the
contact_grid
object
whenever the theRecordSet object changes.
The object that receives the notification must include a
modelChanged
callback function to
handle the notification. Whenever the RecordSet object changes, the
modelChanged
function
gets called with a message object that consists of one or more entries, as follows:
•
The first entry,
eventName
, identifies the type of event or change that was made to the record.
•
For some types of events, the message object also includes entries identifying the first and last
record in the record set that were affected by the event.
The types of events that can occur and be specified in the
eventName
property are
addItems
,
allRows
,
fetchRows
,
sort
,
removeItem
,
removeItems
, and
updateItems
. Depending on the
value of
eventName
, the following properties might provide additional information:
firstItem
,
lastItem
,
removedIDs
, and
removedItems
. For descriptions of RecordSet events and properties,
see the RecordSet class in Flash Remoting ActionScript Dictionary Help.
The following example creates a
modelChanged
function that displays a trace message with the
event type and sets it up as the callback handler for changes to the myRecordSet object:
var myObj = new Object();
myObj.modelchanged = function(info)
{
trace("Caught modelChanged event: " + info.eventName);
}
myRecordSet = new RecordSet(["DepartmentID", "DepartmentName"]);
myRecordSet.addEventListener("modelChanged", myObj);
The following example of activity on the
myRecordSet
RecordSet causes the
modelChanged
function to display
addItems
as the event name:
var newDept = {DepartmentID: "6504", DepartmentName: "Customer Relations"};
myRecordSet.addItemAt(15, newDept);
For more information on the
RecordSet.addEventListener()
and
RecordSet.removeEventListener()
methods, see the RecordSet.addEventListener() and the
RecordSetRemoveEventListener in Flash Remoting ActionScript Dictionary Help.
Sorting and filtering record sets
The
RecordSet
class has methods for sorting an existing RecordSet object or creating a new
RecordSet object from an existing one by applying a selection (filter) function.
Содержание FLASH REMOTING MX
Страница 1: ...Using Flash Remoting for Flash MX 2004 ActionScript 2 0...
Страница 8: ...8 Contents...
Страница 62: ...62 Chapter 3 Using the RemotingConnector component Flash Professional only...
Страница 142: ...142 Chapter 7 Using Flash Remoting for Java...