Flash CS3 Documentation |
|||
| 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.
my_list.change = function(evt:Object) {
getURL(evt.target.selectedItem.data, "_blank");
};
my_list.addEventListener("change", my_list);
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.)
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.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.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00003161.html