Datagrid Performance Strategies - MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference

Components language reference
Table of Contents

Advertisement

To create a DataGrid component instance using ActionScript:
1.
Drag the DataGrid component from the Components panel to the current document's
library.
This adds the component to the library, but doesn't make it visible in the application.
2.
Select the first frame in the main Timeline, open the Actions panel, and enter the following
code:
this.createClassObject(mx.controls.DataGrid, "my_dg", 10,
{columnNames:["name", "score"]});
my_dg.setSize(140, 100);
my_dg.move(10, 40);
This script uses the
instance and then sizes and positions the grid.
3.
Create an array, add data to the array, and identify the array as the data provider for the
data grid:
var myDP_array:Array = new Array();
myDP_array.push({name:"Clark", score:3135});
myDP_array.push({name:"Bruce", score:403});
myDP_array.push({name:"Peter", score:25});
my_dg.dataProvider = myDP_array;
4.
Select Control > Test Movie.

DataGrid performance strategies

Performance can quickly become a major concern when you are using the DataGrid
component because the size of the data it displays can be scalable. A data grid that displays a
hundred rows on a fast computer with a fast connection to the data source may look
acceptable to you. A month later, when the data has increased to several thousand rows, a user
may have a much different experience. Also, the user may have a slower computer on a slow
connection to your data source.
Here are some suggestions for avoiding common performance pitfalls when using the
DataGrid component.
Build and bind a data structure rather than add columns directly.
There are two ways to add columns and data to the DataGrid component: by binding a
pre-made data structure (an array of objects) through the
property or by using DataGrid class methods such as
DataGrid.addItem()
using the
DataGrid.dataProvider
columns it needs before attempting to draw them on the screen.
256
DataGrid component (Flash Professional only)
UIObject.createClassObject()
. Whenever possible, you should bind to a pre-made data structure
property because it allows DataGrid to create all the
method to create the DataGrid
DataGrid.dataProvider
DataGrid.addColumn()
and

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents