Skip to main content
Known Participant
January 29, 2011
Answered

gotoAndPlay playing two frames when reaching a certain frame help

  • January 29, 2011
  • 1 reply
  • 811 views

Hi guys wondering if you could help me again?

Basically I have a MC called 'plane3.' Inside that MC is another MC called 'plane2.' Inside 'plane2' is an animation on frame 5.

(inside the MC 'plane3' the MC 'plane2' is on a classic tween going side-to-side from frame 1 to 99, once it gets to frame 99 the code gotoAndPlay(1); makes it go on loop back to the beginning)

My question is how would I go about: when you click 'plane3' it lets the tween continue playing until frame 10, then on frame 10, it gotoAndPlay (100); in the same MC and ALSO plays frame 5 from inside 'plane2'??

Can it be done? Thanks for your help guys!!!

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

If I follow, and if plane2 is inside plane3, and if plane 3 lives on the _root timeline, and if clicking plane3 is supposed to make you go to 100... try

on main time line

var go100 = false;

plane3.onRelease = function(){

        go100 = true;

}

inside MC 'plane3' on frame 10:

if(_root.go100) {

     _root.go100 = false;

      gotoAndPlay (100);

     plane2.gotoAndPlay(5);

}

It will play onwards thru frame 11 if go100 is false, no need to tell it to.

The way you had it, go100 would be false all the time since you didn't target the _root for it (it wouldn't exist in plane3's timeline so it would always be false), and being false it would fall into the else condition which is what I believe you really want it to do when go100 is true

1 reply

Ned Murphy
Legend
January 29, 2011

You could use a variable that you set false initially, and gets set true when you click plane3.  Use that in a conditional in frame 10 to call the commands you want if the value is true... if you called that variable "go100" for example, in frame 10 could have something like...

if(go100){

     go100 = false;  // reset it

     gotoAndPlay(100);

     plane2.gotondPlay(5);

}

Known Participant
January 29, 2011

Hi I have never used Variables before but I have given it a go, however everytime it goes over 10 it does the animation anyway - wether or not i have clicked the plane and made it true! this is what i put. can u point to me what I am doing wrong? thanks:

on main time line I put:

var go100 = false;


_root.plane3.onRelease = function(){

        go100 = true;

}

inside MC 'plane3' I put on frame 10:


if(go100) {

     go100 = false;

     gotoAndPlay(11);

}

else {

      gotoAndPlay (100);

     _root.plane3.plane2.gotoAndPlay(5);

}

thankss!!

Ned Murphy
Ned MurphyCorrect answer
Legend
January 29, 2011

If I follow, and if plane2 is inside plane3, and if plane 3 lives on the _root timeline, and if clicking plane3 is supposed to make you go to 100... try

on main time line

var go100 = false;

plane3.onRelease = function(){

        go100 = true;

}

inside MC 'plane3' on frame 10:

if(_root.go100) {

     _root.go100 = false;

      gotoAndPlay (100);

     plane2.gotoAndPlay(5);

}

It will play onwards thru frame 11 if go100 is false, no need to tell it to.

The way you had it, go100 would be false all the time since you didn't target the _root for it (it wouldn't exist in plane3's timeline so it would always be false), and being false it would fall into the else condition which is what I believe you really want it to do when go100 is true