Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > DataSet component > DataSet.afterLoaded | |||
Flash Player 7.
Flash MX Professional 2004.
Usage 1:
var listenerObject:Object= new Object();listenerObject.afterLoaded = function (eventObj:Object):Void { // ... };dataSetInstance.addEventListener("afterLoaded",listenerObject);
Usage 2:
on (afterLoaded) {
// ...
}
Event; broadcast immediately after the DataSet.items property has been assigned.
The event object (eventObj) contains the following properties:
target The DataSet object that generated the event.
type The string "afterLoaded".
In the following example, a form named contactForm (not shown) is made visible once the items in the data set contact_ds have been assigned.
contact_ds.addEventListener("afterLoaded", loadListener);
var loadListener:Object = new Object();
loadListener.afterLoaded = function (evt_obj:Object) {
if (evt_obj.target == "contact_ds") {
contactForm.visible = true;
}
};
The following example uses the afterLoaded event of the DataSet component to populate the dataProvider property for a List component on the Stage. Drag a List component and a DataSet component to the Stage, and give them instance names of my_list and my_ds, respectively. Add the following ActionScript code to Frame 1 of the main timeline:
my_list.labelField = "name";
var itemsListener:Object = new Object();
itemsListener.afterLoaded = function (evt_obj:Object):Void {
trace("After loaded");
my_list.dataProvider = evt_obj.target.items;
}
my_ds.addEventListener("afterLoaded", itemsListener);
var item_array:Array = [{name:"Douglas"}, {name:"Vinnie"}, {name:"Katherine"}, {name:"David"}];
my_ds.items = item_array;
Flash CS3