4.
In the Actions panel on Frame 1, enter the following code:
myDP = new Array({name:"Chris", price:"Priceless"}, {name:"Nigel",
price:"Cheap"});
myDataGrid.dataProvider = myDP;
The
and
name
price
in each row.
5.
Select Control > Test Movie.
To specify columns and add sorting for a DataGrid component in an
application:
1.
In Flash, select File > New and then select Flash Document.
2.
In the Components panel, double-click the DataGrid component to add it to the Stage.
3.
In the Property inspector, enter the instance name myDataGrid.
4.
In the Actions panel on Frame 1, enter the following code:
var myDataGrid:mx.controls.DataGrid;
// Create columns to enable sorting of data.
myDataGrid.addColumn("name");
myDataGrid.addColumn("score");
var myDP_array:Array = new Array({name:"Clark", score:3135},
{name:"Bruce", score:403}, {name:"Peter", score:25})
myDataGrid.dataProvider = myDP_array;
// Create listener object for DataGrid.
var listener_obj:Object = new Object();
listener_obj.headerRelease = function(evt_obj:Object) {
switch (evt_obj.target.columns[evt_obj.columnIndex].columnName) {
case "name" :
myDP_array.sortOn("name", Array.CASEINSENSITIVE);
break;
case "score" :
myDP_array.sortOn("score", Array.NUMERIC);
break;
}
};
// Add listener to DataGrid.
myDataGrid.addEventListener("headerRelease", listener_obj);
5.
Select Control > Test Movie.
fields are used as the column headings, and their values fill the cells
Using the DataGrid component (Flash Professional only)
255
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers