|
||||||
|
||||||
Flash - Menu that Swings In

Free
Flash Tutorial
![]()
The aim of the tutorial is to learn how to create a Menu with swings in and out. When your mouse goes over the gray Menu Bar to the left, the Flash Menu swings into view. You can then click on the Flash menu buttons. When you move your mouse away from the buttons in the Menu swings away.
Note: Depending on your Browser settings you may need to click on the Movie to activate it:
Example: Download the Flash file Int 104c
Example of a Flash Menu that swings into view.
Update Notes: This Menu tutorial has proved to be one of the most popular tutorials on this site and so I have now fully updated it. This updated tutorial is now compatible with Flash 8 (also Flash MX04). In particular the ActionScript code has been changed so that you can use this Menu in the newer versions of Flash and it is now compatible with both ActionScript 1 and ActionScript 2. The build of the Flash Movie has been simplified and it is now easier to make and a more lean and streamlined Flash file.
Flash Version: This tutorial will work in Flash 8, Flash MX04 and Flash MX. This tutorial has been written specifically with Flash 8 in mind. However users of other versions of Flash should also be able to follow this tutorial without difficulty.
Flash MX Users: You can either follow this tutorial or follow the the original MX tutorial. As the original tutorial was written specifically for MX it maybe easier for you to follow but alas the original tutorial is slightly more complex to build. However the code in the original tutorial has been updated so that you will find that it is forward compatible making it easier to upgrade to the newer versions of Flash: Flash MX Tutorial
Direction X or Y:
It is easy to change the code so that every thing moves from the top. All you need to do is swap the X values for Y values:
Example: Download the Flash file Int 104d
Menu come in from the top on the Y axis's.
Step One: Setting up the Document
Note: You should now be able to see a new Flash document.

Step Two: Creating the Menu Bar
Cross Ref: Flash does not have a Triangle tool but there is a very simple technique: Drawing Triangles


Note: These 55 frames are so that the Menu Bar will be visible throughout the entire Movie. At present the Movie has no content but we will add content. If your content exceeds 55 frames you will need to return to this Layer and add additional frames to ensure that the Menu Bar is visible throughout the Movie.
Step Three: Creating the Graphics

Note: This new Keyframe will contain the content of Menu item one. The new Keyframe does not need to be in Frame 10 but could be on the next unused Frame, which is Frame 2. I have selected to use Frame 10 so that Button 1 will match Frame 10 and Button 2 will match Frame 20 etc. An alterative would be to use Frame Labels (which I do not cover in this tutorial).


Step Four: Creating the Buttons


Note: Make sure your text and your rectangle are different colours!!
Cross Ref: If you do not know how to create buttons see the tutorial: Creating Buttons
Note: My last button returns the user back to the starting point so I have typed Home as the Label.
My six buttons.
Note: Do not place your buttons on the Main Stage. If you have delete them (don't worry they still in the Library).
Step Five: Adding the Menu


Note: All your symbols are still in the Library, none of them have yet been placed on the Main Stage.
All the Symbols in the Library.
Step Six: Placing the Menu



Note: The Menu Bar needs to cover the Buttons which is why it is the top Layer. The Buttons should swing onto the Stage over the Graphics.
Step Seven: ActionScript for the Timeline
The following Actionscript will make the first button move. There is additional code that makes the other buttons follow the first button, a bit like follow the leader.
// sets the x position for the menu to stop and
go back to. You may need to adjust these two settings
var goto = 30;
var backto = -80;
// declares a variable called go which will be used to help create the movement
var go = 0;
// sets the speed - don't set it too slow
setInterval(mousePosition, 5);
// this function is called by the word 'mousePosition'
in the setInterval above
function mousePosition() {
// sets the x position
for the mouse to activate the menu movement
if (_xmouse<=20)
{ //adjust number as necessary
MC1._x =
MC1._x+bounce("right");
}
if (_xmouse>=110) { //adjust number as necessary
MC1._x =
MC1._x-bounce("left");
}
}
// this function is called by 'bounce'
in the mousePosition function above
function bounce(leftOrRight) {
//
sets the swing properties
if
(leftOrRight == "right")
{
go = (goto-MC1._x);
go *= .09;
}
if (leftOrRight == "left")
{
go -= (backto-MC1._x);
go *= .09;
}
return go;
}
Note: If you are struggling to understand the functions above see the tutorial: Intro to functions

So far only the first Button works.
Note: Only one Button will work. To make the rest of the Buttons work there one more step.
Step Eight: ActionScript for the Movie Clips
The ActionScript below makes sure that the Movie Clips follow the lead of Movie Clip 1.
Script Assist is off when there is: No Tick
Cross Ref: If you do not know about Script Assist or struggle with the Actions Panel look here: Actions Panel
Tip: In the top left of the Actions Panel you must be able to read:
Note:
The code for MC 2 refers back to MC 1,
The code for MC 3 refers back to MC 2,
The code for MC4 refers back to MC3,
etc.

All the Buttons works.
Step Nine: Making the Menu Buttons Work
Although the Menu should now be working correctly the Buttons don't actually function. This last section will make them function correctly
Open MC1 by double clicking on: Movie Clip 1
Tip: In the top left of the Actions Panel you must be able to read:
Note: All your Buttons should now work.
Your Movie should have a Menu that swings in with buttons that go to different locations in your Flash Movie. I hope you found this tutorial useful and easy to follow.
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
90961 visitors to this page since
March 06 •
|
|
|

Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend:
Click here
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|