User Guide

316 DataHolder component (Flash Professional only)
DataHolder.data
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX Professional 2004.
Usage
dataHolder.data
Description
Property; the default item in a DataHolder object’s schema. This property is not a
permanent” member of the DataHolder component. Rather, it is the default bindable
property for each instance of the component. You can add your own bindable properties, or
delete the default
data property, by using the Schema tab in the Component inspector.
For more information on using the Schema tab, see “Working with schemas in the Schema
tab (Flash Professional only)” in Using Flash.
Example
For a step-by-step example of using this component, see “Creating an application with the
DataHolder component (Flash Professional only)” on page 314.
The following code shows a simple example of how to populate the DataHolder component
with data that is a variable. To test the application, you enter a value into the text input field
and click the
addDate_btn instance, which adds the value to the DataHolder component.
Click the
dumpDataHolder_btn instance to trace the contents of the DataHolder component.
// Drag two Button components onto the Stage (addDate_btn and
dumpDataHolder_btn), a TextInput (myDate_txt) and a DataHolder
(myDataHolder). Add the following ActionScript to Frame 1:
var dhListener:Object = new Object();
dhListener.click = function() {
trace("dumping DataHolder");
trace(" " + myDataHolder.myDate);
trace("");
};
var dateListener:Object = new Object();
dateListener.click = function() {
myDataHolder.myDate = myDate_txt.text;
trace("added value");
};
this.dumpDataHolder_btn.addEventListener("click", dhListener);
this.addDate_btn.addEventListener("click", dateListener);