|
|
Search Tutorials
The Actionscript: part 5Listbox functionsWe now have to create listbox functions. The first function is the changehandler for the listbox called chooseMenu(myList). First we clear our movieholder, then we define the Value of the listbox, which is the var modelDescription. If that is not undefined, then we either upload a textfile with the description or if we access the description as the first child in our XML file. //listbox changeHandler function
function chooseMenu(myList) {
movieHolder.unloadMovie();//we clear the movieholder, every time a listbox
//item is selected. "modelDescription" is the value for each item.
modelDescription = myList.getValue();
if (myList.getValue()!=undefined){
//we either execute the loadVars function(see above) or show the nodeValue
//in the main textfield "InstanceName_0.text" depending on what
//modelDescription will hold. When you execute this with "Test Movie",
//there will be a complain, because either hasn't been found but that does not
//matter for execution of the movie itself.
loadText(modelDescription);
InstanceName_0.text = modelDescription;
}
}
The actual function combining the list and changehandler is chooseModel(model,description). We define here by myList.addItem() that to each modelName model there will be a modelDescription description. Then we set the changehandler function, which we have defined above so that whenever the user clicks on an item (model) the corresponding whatever it is (description) is shown. This can be a url, movie, picture, anything which we define. //function for the listbox
function chooseModel(model,description){
//this script defines the item "model", which is "modelName" and its
//value description, which is "modelDescription". All items will be listed.
myList.addItem(model,description);
//this will execute the above function and only one item be selected.
chooseMenu(myList);
myList.setChangeHandler("chooseMenu");
}
|
||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|