import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
btnHome.addEventListener(MouseEvent.ROLL_OVER, buttonOver);
btnAbout.addEventListener(MouseEvent.ROLL_OVER, buttonOver);
btnServices.addEventListener(MouseEvent.ROLL_OVER, buttonOver);
btnContact.addEventListener(MouseEvent.ROLL_OVER, buttonOver);
btnHome.addEventListener(MouseEvent.ROLL_OUT, buttonOut);
btnAbout.addEventListener(MouseEvent.ROLL_OUT, buttonOut);
btnServices.addEventListener(MouseEvent.ROLL_OUT, buttonOut);
btnContact.addEventListener(MouseEvent.ROLL_OUT, buttonOut);
btnHome.addEventListener(MouseEvent.CLICK, buttonClick);
btnAbout.addEventListener(MouseEvent.CLICK, buttonClick);
btnServices.addEventListener(MouseEvent.CLICK, buttonClick);
btnContact.addEventListener(MouseEvent.CLICK, buttonClick);
function buttonOver(event:MouseEvent):void {
event.currentTarget.gotoAndPlay(“over”);
}
function buttonOut(event:MouseEvent):void {
event.currentTarget.gotoAndPlay(“out”);
}
btnHome.buttonMode = true;
btnAbout.buttonMode = true;
btnServices.buttonMode = true;
btnContact.buttonMode = true;
var home:pageHome = new pageHome();
var about:pageAbout = new pageAbout();
var services:pageServices = new pageServices();
var contact:pageContact = new pageContact();
var currentPage:MovieClip = home;
var nextPage:MovieClip;
btnHome.mcTarget = home;
btnAbout.mcTarget = about;
btnServices.mcTarget = services;
btnContact.mcTarget = contact;
addChild(home);
home.alpha = 0;
home.x = 32.5;
home.y = 288;
var myTween = new Tween(home, “alpha”, Strong.easeOut, 0, 1, 3, true);
function buttonClick(event:MouseEvent):void {
btnHome.enabled = false;
btnAbout.enabled = false;
btnServices.enabled = false;
btnContact.enabled = false;
btnHome.removeEventListener(MouseEvent.CLICK, buttonClick);
btnAbout.removeEventListener(MouseEvent.CLICK, buttonClick);
btnServices.removeEventListener(MouseEvent.CLICK, buttonClick);
btnContact.removeEventListener(MouseEvent.CLICK, buttonClick);
nextPage = event.currentTarget.mcTarget;
var offTween:Tween = new Tween(currentPage, "alpha", Strong.easeOut, 1,0,10, false);
offTween.addEventListener(TweenEvent.MOTION_FINISH, onTween);
}
function onTween(event:TweenEvent):void {
removeChild(currentPage);
currentPage = nextPage;
currentPage.alpha = 0;
currentPage.x = 32.5;
currentPage.y = 288;
addChild(currentPage);
currentPage.gotoAndPlay(1);
var tweenOn:Tween = new Tween(currentPage, “alpha”, Strong.easeOut, 0,1,10, false);
tweenOn.addEventListener(TweenEvent.MOTION_FINISH, buttonEnable);
}
function buttonEnable(event:TweenEvent):void {
btnHome.enabled = true;
btnAbout.enabled = true;
btnServices.enabled = true;
btnContact.enabled = true;
btnHome.addEventListener(MouseEvent.CLICK, buttonClick);
btnAbout.addEventListener(MouseEvent.CLICK, buttonClick);
btnServices.addEventListener(MouseEvent.CLICK, buttonClick);
btnContact.addEventListener(MouseEvent.CLICK, buttonClick);
}
///////////////////////////////////////////////////////////////////////////
this is my code, when im testing the movie, the movie is doing good unless when you return to the button that you clicked, still you can see the children movieclips that will be found in the page…
this is the code of my button.
////////////////////////////////////////////////////////////////////////
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var profileStartY:Number = btnProfile.y;
var teamStartY:Number = btnTeam.y;
var btnStop:Number = 0;
var btnStop1:Number = 0;
var duration:Number = 1.2;
var btnprofileMC:btnprofile_mc = new btnprofile_mc();
var btnteamMC:btnteam_mc = new btnteam_mc();
btnProfile.buttonMode = true;
btnTeam.buttonMode = true;
function buttonOver1(event:MouseEvent):void {
event.currentTarget.gotoAndPlay(“over1”);
}
function buttonOut1(event:MouseEvent):void {
event.currentTarget.gotoAndPlay(“out1”);
}
function buttonTeam(event:MouseEvent):void {
if (btnProfile.y == -192.6) {
profileStartY = btnProfile.y;
btnStop = -150;
var profileBody:Tween = new Tween(btnProfile, “y”, Strong.easeInOut, profileStartY, btnStop, duration, true);
if (addChild(btnprofileMC)) {
removeChild(btnprofileMC);
}
profileBody.addEventListener(TweenEvent.MOTION_FINISH, tweenTeam);
} else {
profileStartY = btnProfile.y;
btnStop = -150;
var profileBody1:Tween = new Tween(btnProfile, "y", Strong.easeInOut, profileStartY, btnStop, duration, true);
if (addChild(btnprofileMC)) {
removeChild(btnprofileMC);
}
profileBody1.addEventListener(TweenEvent.MOTION_FINISH, tweenTeam);
}
function tweenTeam(event:TweenEvent):void {
addChild(btnteamMC);
var myTween = new Tween(btnteamMC, "alpha", Strong.easeOut, 0, 1, 1, true);
btnteamMC.x = 23.2;
btnteamMC.y = -190.2;
btnteamMC.btnMigs.buttonMode = true;
btnteamMC.btnJoey.buttonMode = true;
var buttonsArray:Array = [btnteamMC.btnMigs ,btnteamMC.btnJoey];
function setButtons():void {
for (var i:int=0; i<buttonsArray.length; i++) {
buttonsArray*.pages = i;
buttonsArray*.buttonMode = true;
buttonsArray*.mouseChildren = false;
buttonsArray*.mouseEnabled = true;
buttonsArray*.addEventListener(MouseEvent.ROLL_OVER,buttonOver2);
buttonsArray*.addEventListener(MouseEvent.ROLL_OUT,buttonOut2);
buttonsArray*.addEventListener(MouseEvent.CLICK,doClick);
}
}
function buttonOver2(event:MouseEvent):void {
event.currentTarget.gotoAndPlay("over2");
}
function buttonOut2(event:MouseEvent):void {
event.currentTarget.gotoAndPlay("out2");
}
function doClick(event:MouseEvent):void {
var currentBtn:int = event.currentTarget.pages;
setSelectedBtn(currentBtn);
}
function setSelectedBtn(id:int):void {
for (var i:int=0; i< buttonsArray.length; i++) {
if (id == i) {
buttonsArray*.gotoAndStop("down2");
buttonsArray*.buttonMode = false;
buttonsArray*.mouseEnabled = false;
buttonsArray*.removeEventListener(MouseEvent.ROLL_OVER,buttonOver2);
buttonsArray*.removeEventListener(MouseEvent.ROLL_OUT,buttonOut2);
buttonsArray*.removeEventListener(MouseEvent.CLICK,doClick);
} else {
if (buttonsArray*.currentLabel =="down2") {
buttonsArray*.gotoAndPlay("out2");
}
buttonsArray*.buttonMode = true;
buttonsArray*.mouseEnabled = true;
buttonsArray*.addEventListener(MouseEvent.ROLL_OVER,buttonOver2);
buttonsArray*.addEventListener(MouseEvent.ROLL_OUT,buttonOut2);
buttonsArray*.addEventListener(MouseEvent.CLICK,doClick);
}
}
}
setButtons();
}
}
btnTeam.addEventListener(MouseEvent.ROLL_OVER,buttonOver1);
btnTeam.addEventListener(MouseEvent.ROLL_OUT,buttonOut1);
btnTeam.addEventListener(MouseEvent.CLICK, buttonTeam);
///////////////////////////////////////////////////////////////////////////////////////////////////////
function buttonProfile(event:MouseEvent):void {
if (btnProfile.y == -150) {
removeChild(btnteamMC);
profileStartY = btnProfile.y;
btnStop = -192.6;
var profileBody:Tween = new Tween(btnProfile, “y”, Strong.easeInOut, profileStartY, btnStop, duration, true);
profileBody.addEventListener(TweenEvent.MOTION_FINISH, tweenProfile);
} else {
profileStartY = btnProfile.y;
btnStop = -192.6;
var profileBody1:Tween = new Tween(btnProfile, “y”, Strong.easeInOut, profileStartY, btnStop, duration, true);
profileBody1.addEventListener(TweenEvent.MOTION_FINISH, tweenProfile);
}
function tweenProfile(event:TweenEvent):void {
addChild(btnprofileMC);
var myTween = new Tween(btnprofileMC, “alpha”, Strong.easeOut, 0, 1, 1, true);
btnprofileMC.x = 23.2;
btnprofileMC.y = -165.2;
btnprofileMC.btnAboutUs.buttonMode = true;
btnprofileMC.btnPhilo.buttonMode = true;
var buttonsArray:Array = [btnprofileMC.btnAboutUs ,btnprofileMC.btnPhilo];
function setButtons():void {
for (var i:int=0; i<buttonsArray.length; i++) {
buttonsArray*.id = i;
buttonsArray*.buttonMode = true;
buttonsArray*.mouseChildren = false;
buttonsArray*.mouseEnabled = true;
buttonsArray*.addEventListener(MouseEvent.ROLL_OVER,buttonOver2);
buttonsArray*.addEventListener(MouseEvent.ROLL_OUT,buttonOut2);
buttonsArray*.addEventListener(MouseEvent.CLICK,doClick);
}
}
function buttonOver2(event:MouseEvent):void {
event.currentTarget.gotoAndPlay("over2");
}
function buttonOut2(event:MouseEvent):void {
event.currentTarget.gotoAndPlay("out2");
}
function doClick(event:MouseEvent):void {
var currentBtn:int = event.currentTarget.id;
setSelectedBtn(currentBtn);
}
function setSelectedBtn(id:int):void {
for (var i:int=0; i< buttonsArray.length; i++) {
if (id == i) {
buttonsArray*.gotoAndStop("down2");
buttonsArray*.buttonMode = false;
buttonsArray*.mouseEnabled = false;
buttonsArray*.removeEventListener(MouseEvent.ROLL_OVER,buttonOver2);
buttonsArray*.removeEventListener(MouseEvent.ROLL_OUT,buttonOut2);
buttonsArray*.removeEventListener(MouseEvent.CLICK,doClick);
} else {
if (buttonsArray*.currentLabel =="down2") {
buttonsArray*.gotoAndPlay("out2");
}
buttonsArray*.buttonMode = true;
buttonsArray*.mouseEnabled = true;
buttonsArray*.addEventListener(MouseEvent.ROLL_OVER,buttonOver2);
buttonsArray*.addEventListener(MouseEvent.ROLL_OUT,buttonOut2);
buttonsArray*.addEventListener(MouseEvent.CLICK,doClick);
}
}
}
setButtons();
}
}
btnProfile.addEventListener(MouseEvent.ROLL_OVER,buttonOver1);
btnProfile.addEventListener(MouseEvent.ROLL_OUT,buttonOut1);
btnProfile.addEventListener(MouseEvent.CLICK, buttonProfile);
/////////////////////////////////////////////////////////////////////////////
how can i improve my coding? im just new in scripting…thanks a lot
////////////////////////////////////////////////////////////////////////////