Playing Movie Clip Backwards

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.

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

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 . . .

Ok, I wrote a prototype that does exactly what you want a little while ago … let me see if I can find it back.

Here it is =)


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;
	};
};

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.

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

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

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

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


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

*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! :smiley:
**

Lol, what senocular is doing on a Friday evening … :stuck_out_tongue:

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

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

**

Why didn’t I think of that ? :stuck_out_tongue:

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

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

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

menu.home.playAndStop(0,11)

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

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 . . .

[search][/search] for ‘preloader’ :wink: