User Guide

202 ComboBox component
Description
Method; sorts the items in the combo box according to the specified compare function or
according to the specified sort options.
Example
This example sorts according to uppercase labels. The items a and b are passed to the function
and contain
label and data fields:
myComboBox.sortItems(upperCaseFunc);
function upperCaseFunc(a,b){
return a.label.toUpperCase() > b.label.toUpperCase();
}
The following example uses the upperCaseFunc() function defined above, along with the
optionsFlag parameter to sort the elements of a ComboBox instance named myComboBox:
myComboBox.addItem("Mercury");
myComboBox.addItem("Venus");
myComboBox.addItem("Earth");
myComboBox.addItem("planet");
myComboBox.sortItems(upperCaseFunc, Array.DESCENDING);
// The resulting sort order of myComboBox will be:
// Venus
// planet
// Mercury
// Earth
ComboBox.sortItemsBy()
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
comboBoxInstance.sortItemsBy(fieldName, order [optionsFlag])
Parameters
fieldName A string that specifies the name of the field to use for sorting. This value is
usually
"label" or "data".
order A string that specifies whether to sort the items in ascending order ("ASC") or
descending order (
"DESC").