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

Free
Flash Tutorial
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.
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
69677 visitors to this page since
March 06 •
|
|
|
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.
|