User Guide
Table Of Contents
- Contents
- About Flash Remoting
- Getting Started
- Using Flash Remoting ActionScript
- Using the RemotingConnector component (Flash Professional only)
- Using Flash Remoting Data in ActionScript
- About Flash Remoting and data types
- Understanding Action Message Format
- Converting from ActionScript to application server data types
- Converting from application server data types to ActionScript
- ColdFusion to ActionScript data conversion issues
- About working with objects
- About working with RecordSet objects
- About working with XML
- The NetConnection Debugger
- Using Flash Remoting with ColdFusion MX
- Using Flash Remoting for Java
- About Flash Remoting for Java
- Calling Java classes or JavaBeans from ActionScript
- Calling Enterprise JavaBeans (EJBs) from Flash
- Calling servlets and JSPs from Flash
- Calling JMX MBeans from Flash (JRun only)
- Calling server-side ActionScript from Flash (JRun only)
- Handling function results in ActionScript
- Using Flash Remoting with JRun security
- Passing XML objects between Flash and Java
- Viewing Flash Remoting log entries
- Using Flash Remoting for Microsoft .NET
- Flash Remoting for Microsoft .NET
- Calling ASP.NET pages from Flash
- Making an ASP.NET page available to Flash Remoting
- Getting a reference to an ASPX-based service in ActionScript
- Invoking ASPX pages in ActionScript
- Using the Flash Remoting custom server control in ASPX pages
- Using the Flash Remoting namespace in code-behind files
- Using ASP.NET state management with Flash Remoting
- Using ASP.NET exception handling
- Using ADO.NET objects with Flash Remoting
- Displaying a RecordSet object in Flash with ActionScript
- Calling web services from Flash
- Calling ASP.NET assemblies from Flash
- Viewing Flash Remoting log entries
- Using NetServices and Connection Classes
- Index

80 Chapter 4: Using Flash Remoting Data in ActionScript
Sorting record sets
To sort the records of a RecordSet object, use the sortItems and sortItemBy() methods. The
sortItemBy() method performs an ascending (the default) or descending sort on the records in
the RecordSet object. The
sortItems() method requires a comparison function as an argument,
and uses that function to sort the records. The
sortItemsBy() method is implemented natively
in Flash Player 7.x and is substantially faster than the
sortItems() method.
Sorting a RecordSet object changes the order of the records in the object, but does not otherwise
change the object. Subsequent calls to the
getItemAt() method return records according to the
new order. After you sort a RecordSet object that was returned from an application, the object no
longer reflects the order of the records on the server-side record set.
The following one-line example sorts the myRecordSet object according to the value of the
DepartmentName field in descending order:
myRecordSet.SortItemsBy("DepartmentName", null, Array.DESCENDING);
The following example sorts a record set prior to displaying it in a ListBox UI component:
function onCustData( re:ResultEvent ):Void {
var rs:RecordSet = RecordSet( re.result );
rs.sortItemsBy(["TotalSales","Name"], null, Array.DESCENDING |
Array.NUMERIC);
DataGlue.bindFormatFunction( cust_ListBox, rs, formatSales);
}
In this example, cust_ListBox represents a ListBox UI component in the Flash application. In
the
rs.sortItemsBy() method, it sorts the records according to the contents of the TotalSales
column in descending order.
For an example of using the
sortItems() method, see the RecordSet.sortIems() method in Flash
Remoting ActionScript Dictionary Help.
Note: For RecordSet objects containing 2,000 or fewer records, the sortItems() method generally
takes less than one second to finish on a Pentium 3 computer. The length of time to sort RecordSet
objects increases rapidly as the number of records grows.
Filtering an existing RecordSet object to create a new RecordSet object
The filter() method creates a filtered view of a RecordSet object that contains only records that
conform to a set of rules specified by a selection (filter) function that you define. Unlike the
sortItems() method, the filter() method creates a new RecordSet object. The original
RecordSet object and its records remain unchanged.
The selection function that you define takes a record as the first argument, and can take an
optional second argument to determine how to select the records. The function must return a
Boolean
true or false value. Flash Remoting includes in the filtered RecordSet those records for
which the selection function returns
true. When you call the filter() method, you pass it your
selection function and, optionally, the value to use as the selection function’s second argument.
The
RecordSet.filter() method calls the selection function once for each record in the record
set.