[MX] How to create sequential code

I was just wondering if there is a nicer way than setting flag variables etc. to accomplish this.

Example: trying to have a pannel slide closed, then it opens with the text. The text is changed and displayed by the time it opens.

When I have something like

movie.gotoAndPlay(“CloseWindow”); //line 1
text.gotoAndPlay(“ShowText”); //line 2

The problem is both processes start and you see the new text as the window closes.
Is there a way to have your code not execute the next line until the previous line is complete?
e.g. if movie was finished playing, then perform line 2.

Any tutorials kicking around on doing what I am doing? I know there are tons of ways to do it… just wondering if there are some slick functions etc. that might even do the above.

I’m thinking direct linking…

In your first movie… At the very end of it… Have

_root.text.gotoAndPlay(“ShowText”);

And not have it back to back in the coding screen… So just have it at the end of the first movie.

problem is that the text changes, so isn’t always the same frame called of the “text movie”.

I guess I could have an event handler (i.e. just call a function) when the curtain is closed (1/2 way through first movie).

Then that function would need to determine which text.frame to play.

You can do that also… :wink:

Yeah, that works… just was thinking would like to not have code in the movie clip…

Is there frame methods? (I mean doing this with just one method i.e. line of code)

Like could I tell it to play a movie clip until frame x?

e.g. gotoAndPlay(and stop at hehehe…)

Well You can somewhat do that… There really isn’t a command to do it… I also have another method for the above that you don’t have to put actual CODE in the movieClip.

Here is the answer to your first question…


MovieClip.prototype.playTil = function(thisFrame)
{
   if(this._currentframe != thisFrame)
   {
      this.play();
   } else {
      this.stop();
   }
}

Just call that function like this…

movie.playTil(15);

That should help you out there and as for the other one…


if(movie._currentframe == movie._totalframes)
{
   movie2.play();
}

There ya go… See if that works out for ya buddy :wink:

Thanks a ton !

I will check this out as soon as I get back.

I like the function you gave, looks like it will work - have to try still.

But the second one you gave… do you really think it will work?

I mean from what I have been playing with MX that will execute once since it isn’t in a loop and movie2 will never run (if the first movie isn’t done yet).

I tried putting that in a while loop, but then the result is things just freeze right up while the code keeps checking.

But thanks a bunch for the function that looks very cool, will try it out.