Saturday, July 21, 2007

Making Menus in Flash: Component Menu

Thanks for coming back or if your here for the first time I'm glad to have you over. If your not familiar with the site, I have been putting my 3D duties on hold, to try to create a flash based video game, based on the highly popular DDR series. As I am beginning the actual programming process, I'm taking a step back to create a START page and adding another menu to the game interface. So I'll begin by explaining both menu's, the START menu is going to be a hard coded component based drop down menu, where as the second menu will be a flash based button menu. Let's begin with the component menu:

1. First, if you haven't read the previous post, here is my generic layout for the game, and I've transferred it to the START page. I've already added the text "Select a Skill Level" and so I'm ready to create my dropdown menu.


2. Next, select from the menu, Window, and then Components.


3. You will see a Component Box filled with various form components that are usually reserved for our old JavaScript days. Drag and drop a ComboBox into the scene. I have idea why they didn't name it DropDown Box or Menu, maybe due to copyright.


4. Use the Free Transform tool, to increase the horizontal scale of the Combobox. Why? Because it just looks better.


5. Now, lets fill it up with options. So go back to the Window Menu and choose Component Inspector.


6. We can't just input Words, into the ComboBox, because each position on the box, represents a number (everything is a number these days). The number will come into play during the programming portion. So I figure that I will have four skill sets, "Beginner, Intermediate, Hard, and Expert." Therefore, if the Values of the position begin at zero then I should only go up to 3, so click the 'plus' sign and keep adding numbers until you get to three.



Then click on the labels portion, and input in whatever titles you want to be selected by the menu, again for me it was "Beginner, Intermediate, Hard, and Expert."


7. So now to complete the layout before the programming, we have to include a button because just selected an option from the menu won't instruct Flash. Therefore, a button must be used. So I just put together a simple rectangle and converted it to a button and then put the word 'start' within the button.


8. Now select the ComboBox, and name the ComboBox in the Properties box. What did I name the box, 'ddrbox'



Next select the button and open the action panel. So here's the easiest part of the whole process.......that's just copying and pasting the following code that I have already written. Just replace the 'ddrbox' with the name of your ComboBox.

on(release)
{
if(ddrbox.getValue()== 0)
{
gotoAndPlay(2);
}
if(dddrbox.getValue()== 1)
{
gotoAndPlay(3);
}
if(ddrbox.getValue() == 2)
{
gotoAndPlay(4);
}
if(ddrbox.getValue() == 3)
{
gotoAndPlay(5);
}
}

To modify your menu to do something else, you can replace the gotoAndPlay() with geturl() and you will be able to direct users to websites. In the second half of this tutorial, I'll explain how to make Flash button based menus, and stay tuned to the Making Flash DDR, series as I constantly update it with plenty of useful information.

Well, good luck and if you have any QUESTIONS, not 'oh my god I hate your freaking guys because you have no life and blog all day' type comments.

5 comments:

Anonymous said...

I have followed all your steps and I presume you have to create frames 2 - 4 from looking at the code. However once I create the next frame the flash itself just repeatedly flash between the first frame and second frame (per say). How am I to counter that?

Anonymous said...

I've read through the tutorial several times and I cannot figure out how to make the ComboBox work. I can get it on the screen, but once I get to the Component Inspector, I have not the slightest idea how to continue on. I am using Flash 8, if this helps.
Thanks.

Francis Br. said...

Ok, im just a 14 years old intermediate programmer .... i followed all your instrucions and it worked perfectly, im just itching to see how you make the screen scroll as the arrows pass thru it ...

Evilnms said...

Wouldn't it be easier just to use a GotoAndStop() version?

Anonymous said...

I found this site using [url=http://google.com]google.com[/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic

Anonymous Posting Is Allowed and Click on Pics to Enlarge