ActionScript 2.0 Components Language Reference |
|
|
|
| List component > Using the List component > Creating an application with the List component | |||
The following procedure explains how to add a List component to an application while authoring. In this example, the list is a sample with three items.
To add a simple List component to an application:
my_list.change = function(evt:Object) {
getURL(evt.target.selectedItem.data, "_blank");
};
my_list.addEventListener("change", my_list);
To populate a List instance with a data provider:my_list.dataProvider = myDP;
If you have defined a data provider named myDP, the list fills with data. (For more information about data providers, see List.dataProvider.)
To use a List component to control a movie clip instance
my_list.addItem({label:"play", data:"play"});
my_list.addItem({label:"stop", data:"stop"});
var listHandler:Object = new Object();
listHandler.change = function(evt:Object) {
switch (evt.target.selectedItem.data) {
case "play" :
my_mc.play();
break;
case "stop" :
my_mc.stop();
break;
default :
trace("unhandled event: "+evt.target.selectedItem.data);
break;
}
};
my_list.addEventListener("change", listHandler);
my_mc movie clip instance.
To create a List component instance using ActionScript:This adds the component to the library, but doesn't make it visible in the application.
this.createClassObject(mx.controls.List, "my_list", 1);
my_list.addItem({label:"One", data:dt1});
my_list.addItem({label:"Two", data:dt2});
This script uses the method UIObject.createClassObject() to create the List instance.
|
|
|
|