# Playing Movie Clip Backwards

**URL:** https://forum.kirupa.com/t/playing-movie-clip-backwards/34908
**Category:** flash
**Created:** [November 7, 2003, 7:34pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908 "2003-11-07T19:34:33Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![jhargrave](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@jhargrave](https://forum.kirupa.com/u/jhargrave)
#### Post date: [November 7, 2003, 7:34pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/1 "2003-11-07T19:34:33Z")

</div>

I know that this has been the topic of much discussion, and I have searched (unsuccessfully) this forum, Macromedia’s, and the one a Google. So here goes:

I have a movie clip loaded into another. In this clip, I have different images, each motion-tweened into position every 11 frames. There is a stop on each 11th frame, therefore I can easily control the forward motion of the movie with a “forward” button in the parent movie.

However, I am having difficulty making a backward button that will stop on every 11th frame. I have used the following code successfully, but it just plays all the way back to frame 1, then stops.

myButton.onRelease = function() {  
\_root.myClip.onEnterFrame = function() {  
this.prevFrame();  
};

How do I tell it to stop on every 11th frame?

Thanks in advance.

---

<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: [November 7, 2003, 8:06pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/2 "2003-11-07T20:06:28Z")

</div>

Stop on every frame ? So you want it to stop, pause for a second or what ?, and then continue playing backwards ?

---

<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: [November 7, 2003, 8:09pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/3 "2003-11-07T20:09:09Z")

</div>

No, I would like it to play (in reverse) at the frame speed of the movie for 11 frames, then stop. I do not want it to play again until the backward (or forward) button is pressed.

If the backward button is pressed again, it should play (in reverse) for 11 more frames, then stop again . . .

---

<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: [November 7, 2003, 8:11pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/4 "2003-11-07T20:11:22Z")

</div>

Ok, I wrote a prototype that does exactly what you want a little while ago … let me see if I can find it 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: [November 7, 2003, 8:28pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/5 "2003-11-07T20:28:53Z")

</div>

Here it is =)

```auto

MovieClip.prototype.playAndStop = function(direction, stopAt) {
	// 1 is forward, 0 is backward
	this.onEnterFrame = function() {
		direction ? this.nextFrame() : this.prevFrame();
		this._currentframe == stopAt ? delete this.onEnterFrame : null;
	};
};

```

---

<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: [November 7, 2003, 8:46pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/6 "2003-11-07T20:46:59Z")

</div>

Thanks for the help, but I’m not sure that I understand. Would I enter specific frame for the ? where you have “stopAt ?” I don’t think this will work, because I want it to stop after playing 11 frames, regardless of which frame it is.

---

<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: [November 7, 2003, 8:49pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/7 "2003-11-07T20:49:03Z")

</div>

you know Voetsjoeba, using an if statement is less work than the ?: null thing you seem to so much. 2 characters less typing! 😃

and just to clearify on the use of that playAndStop method, when the backward button is pressed, it should run:

```auto
movie.playAndStop(0,movie._currentframe-11);

```

---

<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: [November 7, 2003, 8:49pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/8 "2003-11-07T20:49:43Z")

</div>

Ooh … I thought you wanted it to stop at every 11th frame. Ok, let’s see, that would make …

```auto

MovieClip.prototype.playAndStop = function(direction, amount) {
        var am = 0
        this.onEnterFrame = function() {
am++
                direction ? this.nextFrame() : this.prevFrame();
                am == amount ? delete this.onEnterFrame : null;
        };
};

```

---

<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: [November 7, 2003, 8:53pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/9 "2003-11-07T20:53:28Z")

</div>

> \*Originally posted by senocular \*  
> \*\*you know Voetsjoeba, using an if statement is less work than the ?: null thing you seem to so much. 2 characters less typing! 😃  
> \*\*

Lol, what senocular is doing on a Friday evening … 😛

> \*Originally posted by senocular \*\*\*  
> and just to clearify on the use of that playAndStop method, when the backward button is pressed, it should run:

```auto
movie.playAndStop(0,movie._currentframe-11);

```

\*\*

Why didn’t I think of that ? 😛

---

<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: [November 7, 2003, 10:31pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/10 "2003-11-07T22:31:56Z")

</div>

Forgive me if I am (more than) a little dense, but I am still not sure how to use the code you are suggesting. Perhaps if you looked at my site, you could tell me if I am asking the right questions.

[http://www.postarchitects.com](http://www.postarchitects.com)

Link to Profile, and then Clients. Next to the word CLIENTS, the forward button works, but the backword button (obviously) doesn’t.

I can attach the .fla if necessary.

Thanks again

---

<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: [November 8, 2003, 7:19am UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/11 "2003-11-08T07:19:55Z")

</div>

It’s a prototype, so you can use it on any movieclip or timeline. The usage is like this:

```auto
menu.home.playAndStop(0,11)

```

For playing the movieclip menu.home 11 frames backwards (0) 🙂

---

<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: [November 12, 2003, 9:58pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/12 "2003-11-12T21:58:44Z")

</div>

Thanks a million! I’m not sure why it works, but it definitely does. :azn:

Now if I could only get my preloaders to work . . .

---

<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: [November 13, 2003, 7:08pm UTC](https://forum.kirupa.com/t/playing-movie-clip-backwards/34908/13 "2003-11-13T19:08:21Z")

</div>

[search][/search] for ‘preloader’ 😉
