Ok, so i’ve got a little dilemma with one of my projects again
I made a nav bar which has 5 movieclips acting as buttons.
I have them with a Rollover, Rollout, and Click stage.
Now the click stage is the trickiest… I want to “disable” the button after it has been clicked and have it stop at the very last frame of the movieclip it’s in.
How can I achieve this?
Here’s the code that was optimized using Arrays and If statements so that the code was modular and was able to compute similar functions for different buttons.
/////// ARRAYS ///////////////////////////////////
// 01. ARRAY STRUCTURE
var arrayContent:Array = new Array(content1_mc,content2_mc,content3_mc,content4_mc,
content5_mc);
var arrayBarButtons:Array = new Array(bar1_mc,bar2_mc,bar3_mc,bar4_mc,bar5_mc);
/////// TEXT FIELDS ///////////////////////////////////
// 02. TEXT FIELDS
// 02A. BAR BUTTON TEXT
bar1_mc.barButton_mc.barButton_text.text = "News & Info";
bar2_mc.barButton_mc.barButton_text.text = "Work";
bar3_mc.barButton_mc.barButton_text.text = "About";
bar4_mc.barButton_mc.barButton_text.text = "Contact";
bar5_mc.barButton_mc.barButton_text.text = "Links";
// 02B. LAST UPDATED TEXT
content1_mc.lastUpdated_text.text = "Last Updated: 08.15.2008";
content2_mc.lastUpdated_text.text = "Last Updated: 08.10.2008";
content5_mc.lastUpdated_text.text = "Last Updated: 08.15.2008";
/////// FUNCTIONS ///////////////////////////////////
// 03. ROLL IN FUNCTION
function stateRollIn(evt:MouseEvent):void
{
evt.currentTarget.gotoAndPlay("over");
}
// 04. ROLL OUT FUNCTION
function stateRollOut(evt:MouseEvent):void
{
evt.currentTarget.gotoAndPlay("out");
}
// 05. CLICK FUNCTION
function stateClick(evt:MouseEvent):void
{
evt.currentTarget.gotoAndPlay("down");
trace(evt.target.name);
clearContent();
var count:Number = arrayBarButtons.length;
var index:Number;
for(var i:Number = 0;i<count;i++){
if(evt.target.name == arrayBarButtons*.name){
index = i;
}
}
arrayContent[index].visible = true;
}
// 06. CLEAR CONTENT FUNCTION
// 06A. CLEAR CONTENT (ALL)
function clearContent():void{
content1_mc.visible = false;
content2_mc.visible = false;
content3_mc.visible = false;
content4_mc.visible = false;
content5_mc.visible = false;
}
// 06A. CLEAR CONTENT (INITIAL)
function clearContentInit():void{
content1_mc.visible = true;
content2_mc.visible = false;
content3_mc.visible = false;
content4_mc.visible = false;
content5_mc.visible = false;
}
/////// LOOPS ///////////////////////////////////
// 07. FOR LOOP STATEMENTS
for (var i:Number = 0;i<arrayBarButtons.length;i++){
arrayBarButtons*.addEventListener(MouseEvent.ROLL_OVER, stateRollIn);
arrayBarButtons*.addEventListener(MouseEvent.ROLL_OUT, stateRollOut);
arrayBarButtons*.addEventListener(MouseEvent.CLICK, stateClick);
arrayBarButtons*.mouseChildren = false;
}
/////// RUN FUNCTIONS ///////////////////////////////////
clearContentInit();
stop();
Thanks everyone in advance!