First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Joachim Schnier | Website: http://www.cancerinform.net/

The Actionscript: part 5

Listbox functions

We 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");
}

» Level Intermediate

Added: 2002-09-17
Rating: 8.83 Votes: 72
(10 being the highest)
» Author
The author is a basic scientist doing cancer research.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.