First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Joachim Schnier | Website: http://www.cancerinform.net/

Creating the menu

The dynamic menu has been described in the Flash 5 Bible. We first create two frames for the menu and all the actionscript, which we distribute over the two frames. For the menubutton we make a movieclip (´menuitem´)containing a button graphic, which we animate. We then insert a dynamic textfield into the graphic, which we name ´textField´. In the ´var´ box for the textfield we enter the variable name ´labelName´. We then make a new movieclip and insert an instance of the menuitem, which we give the name ´menu´. Click on the instance and enter the movieclip name ´menuitemBase´ in the property inspector. Then place an instance of the menu button on the scene in frames 1 and 2 and name this movie clip ´menu´. Next write the actionscript into an external menu and enter this code into an action frame in frame 1:

#include "menu_code.txt"
Enter the following code into an external file, which we call ´menu_code´:
//dynamic menu: code from Flash 5 Bible
//determine the number of buttons and titles to the array
sectionNames = new Array("Carshow","More Cars","My Web Sites");
sectionCount = sectionNames.length;
//space between buttons
menuItemSpacing = 10;
	       _root.menu.menuItemBase.duplicateMovieClip("menuItem_"+i, i);
	       _root.menu["menuItem_"+i].labelName = sectionNames[i-1];
	       if(i != 1){
		          _root.menu["menuItem_"+i]._y = _root.menu["menuItem_"+(i-1)]._y +_root.menu["menuItem_"+(i-1)]._height + menuItemSpacing;
     _root.menu.menuItemBase._visible = false;

     function checkButtons(){
		       currentItem = "menuItem_" + i;
		       if(currentItem != _root.activeItem){
			     _root.menu["menuItem_" + i].gotoAndStop(1);
To change the menu just add new titles into the array separated by a comma.

» Level Intermediate

Added: 2002-06-29
Rating: 6 Votes: 65
(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!
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.