# \[MX\] How to create sequential code

**URL:** https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651
**Category:** flash
**Created:** [February 28, 2003, 10:31pm UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651 "2003-02-28T22:31:02Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![lowprofile](https://avatars.discourse-cdn.com/v4/letter/l/779978/32.png) [@lowprofile](https://forum.kirupa.com/u/lowprofile)
#### Post date: [February 28, 2003, 10:31pm UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/1 "2003-02-28T22:31:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 28, 2003, 10:38pm UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/2 "2003-02-28T22:38:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 28, 2003, 11:57pm UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/3 "2003-02-28T23:57:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 1, 2003, 12:12am UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/4 "2003-03-01T00:12:03Z")

</div>

You can do that also… 😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 1, 2003, 12:19am UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/5 "2003-03-01T00:19:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 1, 2003, 12:24am UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/6 "2003-03-01T00:24:00Z")

</div>

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…)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 1, 2003, 12:49am UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/7 "2003-03-01T00:49:54Z")

</div>

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…

```php

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…

```php

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

```

There ya go… See if that works out for ya buddy 😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 1, 2003, 1:13am UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/8 "2003-03-01T01:13:04Z")

</div>

Thanks a ton !

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 4, 2003, 8:25am UTC](https://forum.kirupa.com/t/mx-how-to-create-sequential-code/14651/9 "2003-03-04T08:25:56Z")

</div>

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.
