PDA

View Full Version : Help with gotoAndPlay


opart
09-03-2008, 02:59 PM
Could someone please help with this!
On the first frame of the timeline I have a button, instance name start. On release of the button I want the playhead to go to frame 2.

I've tried several variations of the code below but I can't get it to work:

on (release) {
start.gotoAndPlay(2);}

Any help would be much appreciated.

chemicaluser
09-03-2008, 03:57 PM
if you are using AS3 it would look something like this

start.buttonMode = true;
start.addEventListener(MouseEvent.CLICK, f_myButton_click);
function f_myButton_click (evt:MouseEvent) : void {
gotoAndPlay (2);
}

In AS2
One way is AS2 is to add the action to the button in self, not the timeline

on (release) {
gotoAndPlay(2);

}

flashaddik
09-03-2008, 04:32 PM
I think maybe your problem would be you can't name the mc "start" as it is taken for use by flash. Try "start_but" instead. If you are going to have the button act as a movie you need to reverse it and make the mc act like a button. Change the button into a movieclip and on the first frame of your root timeline put:


start_but.onRelease = function() {
start_but.gotoAndPlay(2);
}

opart
09-03-2008, 05:05 PM
Didn't work.
This is AS2. I've added the action script to the button and changed the instance name to start_butt.

On release of the button, I want to play frame 2.

on (release) {
start_butt.gotoAndPlay(2);

}

chemicaluser
09-03-2008, 10:16 PM
here is an example in AS2... and also when adding code to the button it self and not the timeline... you don't put

start_butt.gotoAndPlay(2);

its

gotoAndPlay(2);

opart
09-04-2008, 04:21 PM
Relief.