Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gotoAndPlay not working in MC 1

Status
Not open for further replies.

skeletrooper

IS-IT--Management
Jun 2, 2003
19
US
I have a MC instance that functions as a button, in order to get the proper button animation I need. I use a gotoAndPlay(scene, frame) function, but the movie won't goto and play the other scene upon mouseclick. Any ideas? Here's my button:

onClipEvent (load) {
stop ();
var speed = 1;
var direction;
}
onClipEvent (enterFrame) {
if (direction == "ff") {
gotoAndStop (_currentframe+speed);
} else if (direction == "rr") {
gotoAndStop (_currentframe-speed);
}
}
on (rollOver) {
_root.oneOut.direction = "ff";
}
on (rollOut) {
_root.oneOut.direction = "rr";
}
on (release) {
gotoAndPlay("Commercials", 1);
}

The gotoAndPlay line doesn't work. BTW, My MC instance is named "oneOut". Upon button release, the clip plays from its first animation frame (in scene "Home"), but does not got to the "Commercials" scene.

-Wes
 
Instructor Bill (He's had a hard day!) would of answered that you shouldn't be using scenes. My mentor hates scenes!

Here's my proposal...

From movie clips and/or from external .swfs loaded on other levels, you cannot target scene names. You should target a labeled frame instead. Thus, if you're targeting frame 1 of your "Commercials" scene, label that first frame with an unique label such as commer1 (Or whatever suits you... But no number only labels or at least not starting off with a number!), add _root (from movie clips) or _level0 (from external .swfs loaded on other levels) to your path, and simply target that labeled frame, in your button's or frame's actionscript...
Code:
on(release){
    _root.gotoAndplay("commer1");
}

Don't forget the doubles quotes in the gotoAndPlay action, not in the label naming itself.
Works wonders!

Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
Thanks oldnewbie...worked like a charm!

So scenes are bad - they do seem like an afterthought of flash (hard to reference, etc.). But it does keep the timeline organized for us newbies!

Thanks again.
 
No problem! And no, scenes are not necessarily bad, and can work fine in many situations.

Regards,

cubalibre2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top