Menu Functionality Question
Ok, so I'm pretty new to ActionScript 3.0 and unfortunately have no friends that know anything about it. This may and probably is not the best way to set this up but here is my problem. This is just something I'm doing for myself to help me get a better understanding of how things work.
I want each menu item to move when clicked, what I do not want is for any other menu items to be able to be clicked until the original item clicked finishes it's move. Then I want them to be able to be clicked and then again nothing else be able to be clicked until it finishes it's move. Any help would be great. If I'm way off with my method I would like to know that as well so I can get on the road to learning how to do it the right way. If there is an easy way to do this (which there probably is), I would love to know that as well. Thanks in advance!
Code:
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var navMoveIn:Tween;
var navMoveOut:Tween;
home_btn.addEventListener(MouseEvent.CLICK, homeMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
//////////////////////////////////////////////////////////////////// ONE MOVE //
function homeMove(event:MouseEvent):void {
navMoveIn = new Tween(home_btn,"x",Bounce.easeOut,30,50,1,true);
navMoveIn = new Tween(home_btn,"y",Bounce.easeOut,20,30,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMove);
home_btn.addEventListener(MouseEvent.CLICK, homeMoveOut);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (two_btn.x == 100) {
navMoveOut = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
if (three_btn.x == 150) {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
if (four_btn.x == 200) {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
if (five_btn.x == 250) {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
if (six_btn.x == 300) {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
if (seven_btn.x == 350) {
navMoveOut = new Tween(seven_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(seven_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
}
function homeMoveOut(event:MouseEvent):void {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.addEventListener(MouseEvent.CLICK, homeMove);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
//////////////////////////////////////////////////////////////////// TWO MOVE //
function twoMove(event:MouseEvent):void {
navMoveIn = new Tween(two_btn,"x",Bounce.easeOut,80,100,1,true);
navMoveIn = new Tween(two_btn,"y",Bounce.easeOut,20,30,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMoveOut);
home_btn.addEventListener(MouseEvent.CLICK, homeMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (home_btn.x == 50) {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
if (three_btn.x == 150) {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
if (four_btn.x == 200) {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
if (five_btn.x == 250) {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
if (six_btn.x == 300) {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
if (seven_btn.x == 350) {
navMoveOut = new Tween(seven_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(seven_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
}
function twoMoveOut(event:MouseEvent):void {
navMoveIn = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
//////////////////////////////////////////////////////////////////// THREE MOVE //
function threeMove(event:MouseEvent):void {
navMoveIn = new Tween(three_btn,"x",Bounce.easeOut,130,150,1,true);
navMoveIn = new Tween(three_btn,"y",Bounce.easeOut,20,30,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMoveOut);
home_btn.addEventListener(MouseEvent.CLICK,homeMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (home_btn.x == 50) {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
if (two_btn.x == 100) {
navMoveOut = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
if (four_btn.x == 200) {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
if (five_btn.x == 250) {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
if (six_btn.x == 300) {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
if (seven_btn.x == 350) {
navMoveOut = new Tween(seven_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(seven_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
}
function threeMoveOut(event:MouseEvent):void {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
//////////////////////////////////////////////////////////////////// FOUR MOVE //
function fourMove(event:MouseEvent):void {
navMoveIn = new Tween(four_btn,"x",Bounce.easeOut,180,200,1,true);
navMoveIn = new Tween(four_btn,"y",Bounce.easeOut,20,30,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMoveOut);
home_btn.addEventListener(MouseEvent.CLICK,homeMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (home_btn.x == 50) {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
if (two_btn.x == 100) {
navMoveOut = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
if (three_btn.x == 150) {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
if (five_btn.x == 250) {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
if (six_btn.x == 300) {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
if (seven_btn.x == 350) {
navMoveOut = new Tween(seven_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(seven_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
}
function fourMoveOut(event:MouseEvent):void {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
//////////////////////////////////////////////////////////////////// FIVE MOVE //
function fiveMove(event:MouseEvent):void {
navMoveIn = new Tween(five_btn,"x",Bounce.easeOut,230,250,1,true);
navMoveIn = new Tween(five_btn,"y",Bounce.easeOut,20,30,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMoveOut);
home_btn.addEventListener(MouseEvent.CLICK,homeMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (home_btn.x == 50) {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
if (two_btn.x == 100) {
navMoveOut = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
if (three_btn.x == 150) {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
if (four_btn.x == 200) {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
if (six_btn.x == 300) {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
if (seven_btn.x == 350) {
navMoveOut = new Tween(seven_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(seven_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
}
function fiveMoveOut(event:MouseEvent):void {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
//////////////////////////////////////////////////////////////////// SIX MOVE //
function sixMove(event:MouseEvent):void {
navMoveIn = new Tween(six_btn,"x",Bounce.easeOut,280,300,1,true);
navMoveIn = new Tween(six_btn,"y",Bounce.easeOut,20,30,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMoveOut);
home_btn.addEventListener(MouseEvent.CLICK,homeMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (home_btn.x == 50) {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
if (two_btn.x == 100) {
navMoveOut = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
if (three_btn.x == 150) {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
if (four_btn.x == 200) {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
if (five_btn.x == 250) {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
if (seven_btn.x == 350) {
navMoveOut = new Tween(seven_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(seven_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
}
function sixMoveOut(event:MouseEvent):void {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
//////////////////////////////////////////////////////////////////// SEVEN MOVE //
function sevenMove(event:MouseEvent):void {
navMoveIn = new Tween(seven_btn,"x",Bounce.easeOut,330,350,1,true);
navMoveIn = new Tween(seven_btn,"y",Bounce.easeOut,20,30,1,true);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMoveOut);
home_btn.addEventListener(MouseEvent.CLICK,homeMove);
two_btn.addEventListener(MouseEvent.CLICK, twoMove);
three_btn.addEventListener(MouseEvent.CLICK, threeMove);
four_btn.addEventListener(MouseEvent.CLICK, fourMove);
five_btn.addEventListener(MouseEvent.CLICK, fiveMove);
six_btn.addEventListener(MouseEvent.CLICK, sixMove);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
if (home_btn.x == 50) {
navMoveOut = new Tween(home_btn,"x",Bounce.easeOut,50,30,1,true);
navMoveOut = new Tween(home_btn,"y",Bounce.easeOut,30,20,1,true);
home_btn.removeEventListener(MouseEvent.CLICK, homeMoveOut);
}
if (two_btn.x == 100) {
navMoveOut = new Tween(two_btn,"x",Bounce.easeOut,100,80,1,true);
navMoveOut = new Tween(two_btn,"y",Bounce.easeOut,30,20,1,true);
two_btn.removeEventListener(MouseEvent.CLICK, twoMoveOut);
}
if (three_btn.x == 150) {
navMoveOut = new Tween(three_btn,"x",Bounce.easeOut,150,130,1,true);
navMoveOut = new Tween(three_btn,"y",Bounce.easeOut,30,20,1,true);
three_btn.removeEventListener(MouseEvent.CLICK, threeMoveOut);
}
if (four_btn.x == 200) {
navMoveOut = new Tween(four_btn,"x",Bounce.easeOut,200,180,1,true);
navMoveOut = new Tween(four_btn,"y",Bounce.easeOut,30,20,1,true);
four_btn.removeEventListener(MouseEvent.CLICK, fourMoveOut);
}
if (five_btn.x == 250) {
navMoveOut = new Tween(five_btn,"x",Bounce.easeOut,250,230,1,true);
navMoveOut = new Tween(five_btn,"y",Bounce.easeOut,30,20,1,true);
five_btn.removeEventListener(MouseEvent.CLICK, fiveMoveOut);
}
if (six_btn.x == 300) {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,300,280,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
six_btn.removeEventListener(MouseEvent.CLICK, sixMoveOut);
}
}
function sevenMoveOut(event:MouseEvent):void {
navMoveOut = new Tween(six_btn,"x",Bounce.easeOut,350,330,1,true);
navMoveOut = new Tween(six_btn,"y",Bounce.easeOut,30,20,1,true);
seven_btn.addEventListener(MouseEvent.CLICK, sevenMove);
seven_btn.removeEventListener(MouseEvent.CLICK, sevenMoveOut);
}
buttonMode = true;