How to play MC backward when it's on end?

Hi!

Can anyone help to solve my problem: I made a very compley shape tween and want it to play backward when it’s end, but I don’t know how. The MC must looping forward and backward.

I don’r have any idea :(. HELP!


MovieClip.prototype.playBackwards = function(){
this.onEnterFrame = function(){
this._currentframe == 1 ? this.prevFrame : delete this.onEnterFrame;
}
}
// Usage:
movieclip.playBackwards();

I tried, but it seems I put the code on wrong place. In _root timeline I have only one frame, in that frame is placed MovieClip which have 43 frames. MovieClipe instance name is drevo_mc. What put where?

What I always do is create a “scriptloop”. A movieclip with three keyframes and the following code on each frame.

Frame 1:

currentFrame = [put your total number of frames here];
stop();

Frame 2:

if (currentFrame != 1) {
	 _root.gotoAndStop(currentFrame - 1);
	 currentFrame -= 1;
} else {
	 gotoAndStop(1);
}

Frame 3:

gotoAndPlay(2);

Drag the scriptloop onto the stage and give it an instance name of something like “scriptloop_rewind” and when you want the movie to go backwards, just use the actionscript:

scriptloop_rewind.gotoAndPlay(2);

Also, please note that the scriptloop must be in EVERY frame of the timeline and that I have assumed you’re trying to rewind the _root timeline. It’s probably best to put the scriptloop on it’s own layer from start to finish.

I tried, but it seems I put the code on wrong place. In _root timeline I have only one frame, in that frame is placed MovieClip which have 43 frames. MovieClipe instance name is drevo_mc. What put where?

In your case, create a new layer in the “drevo_mc” and drag the scriptloop detailed above into that layer. Then change the following line in frame 2:

_root.gotoAndStop(currentFrame - 1);

To…

_root.drevo_mc.gotoAndStop(currentFrame - 1);

And I guess you’ll insert the number 43 into the “currentFrame” variable in Frame 1.

go to the first frame in your base/root movie (the one that contains drevo_mc) and paste V’s code, changing the instance name. It should work for you.

Superb! It works! But here’s a little problem now. When movie clip rewinds, it stops. But i don’t want to do that :slight_smile: Is there possibility that I done somethink wrong? Thanks a LOT for your help!

I tried, but didn’t work. Don’t know why. The **trundrumbalind code **works.

any chance if voets or trund can put together i quick fla. Because i have spent 40 minutes trying it out but doesn’t seem to work. I assume this actionscript works for mx2004.

I’ll post you one in a few minutes mate…

OK, here’s your file. Also note that I’ve changed the line in Frame 2 of the scriptloop from:

_root.drevo_mc.gotoAndStop(currentFrame - 1);

To:

_root.drevo_mc.gotoAndPlay(currentFrame - 1);

This makes the thing loop rather than play, rewind to the beginning and just stop.

Hope this helps, just give me a shout if it’s still not clear from this…

Dave

thanks alot trund. I just didn’t know where to add the scriptloop_rewind.gotoAndPlay(2); code. Now i know

Oh, now I see! That’s work as well. I wonder why Flash haven’t got rewind function integrated. Because this thing is very usefull! Thanks for help!

No problem mate