Creating an application with the DataHolder component

In this example, you add an array property to a DataHolder component's schema (an array) whose value is determined by ActionScript code that you write. You then bind that array property to the dataProvider property of a DataGrid component by using the Bindings tab in the Component inspector.

To use the DataHolder component in a simple application:

  1. Select File > New and choose Flash File (ActionScript 2.0).
  2. Open the Components panel, drag a DataHolder component to the Stage, and name it dataHolder.
  3. Drag a DataGrid component to the Stage and name it namesGrid.
  4. Select the DataHolder component and open the Component inspector.
  5. Click the Schema tab in the Component inspector.
  6. Click the Add Component Property (+) button located in the top pane of the Schema tab.
  7. In the bottom pane of the Schema tab, type namesArray in the Field Name field, and select Array from the Data Type pop-up menu.
  8. Click the Bindings tab in the Component inspector, and add a binding between the namesArray property of the DataHolder component and the dataProvider property of the DataGrid component.
  9. In the Timeline, select the first frame on Layer 1 and open the Actions panel.
  10. Enter the following code in the Actions panel:
    dataHolder.namesArray = [{name:"Tim"},{name:"Paul"},{name:"Jason"}];
    

    This code populates the namesArray array with several objects. When this variable assignment executes, the binding that you established previously between the DataHolder component and the DataGrid component executes.

  11. Test the file by selecting Control > Test Movie.