Skip to main content
Known Participant
October 18, 2009
Answered

framelabels

  • October 18, 2009
  • 1 reply
  • 522 views

Guys,
I need help!

I have a movie clip which contains 5 frame labels : one,two,three,four,five
And I have next and prev button to move around

This is my code


var index:int = 0;

instruction_mc.next_btn.addEventListener(MouseEvent.CLICK, onNext);

function onNext(e:Event):void {    
    index ++;    
    instruction_mc.gotoAndPlay(instruction_mc.currentLabels[index]);    
    if(instruction_mc.currentLabel =="five"){        
        instruction_mc.next_btn.visible = false;
    }

}

Now the problem is,its only play the frame label "one" even though I press next button, it will stays on frame label "one"

but there's no error occured.

I'm confused.

At first I though to put them in an array

but its not working as well :'(

there's one note to be taken, I am required to put all my codes on my main timeline

I can put stop(); inside my other movie clip,but only that actionscript is allowed    *sigh

This topic has been closed for replies.
Correct answer Ned Murphy

Based on the code you show, you do need to have the labels in an array.  According to your code that array is defined inside a movieclip named instruction_mc, and the name of the array is currentLabels.  So inside instruction_mc you should have an array defined...

var currentLabels:Array = new Array("one","two","three","four","five");

Since you say all your code muyst go on the main timeline, it does not make sense that you have code inside instruction_mc.  Maybe your code should be....

stop();

var index:int = 0;

var currentLabels:Array = new Array("one","two","three","four","five");

instruction_mc.next_btn.addEventListener(MouseEvent.CLICK, onNext);

function onNext(e:Event):void {    
    index ++;    
    instruction_mc.gotoAndPlay(currentLabels[index]);    
    if(currentLabels[index] =="five"){        
        instruction_mc.next_btn.visible = false;
    }

}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
October 18, 2009

Based on the code you show, you do need to have the labels in an array.  According to your code that array is defined inside a movieclip named instruction_mc, and the name of the array is currentLabels.  So inside instruction_mc you should have an array defined...

var currentLabels:Array = new Array("one","two","three","four","five");

Since you say all your code muyst go on the main timeline, it does not make sense that you have code inside instruction_mc.  Maybe your code should be....

stop();

var index:int = 0;

var currentLabels:Array = new Array("one","two","three","four","five");

instruction_mc.next_btn.addEventListener(MouseEvent.CLICK, onNext);

function onNext(e:Event):void {    
    index ++;    
    instruction_mc.gotoAndPlay(currentLabels[index]);    
    if(currentLabels[index] =="five"){        
        instruction_mc.next_btn.visible = false;
    }

}

phingkoAuthor
Known Participant
October 18, 2009

THX Ned

I know it is may be a simpel code for u, but I hv been stucked with it for 2 days!

thx man,u rescue me!


Ned Murphy
Legend
October 18, 2009

You're welcome.  We all go thru those long battles, sometimes winning, sometimes losing, but learning something none-the-less.