Jump to content
Search Community

MovieClip that doesn't loop

eigenface test
Moderator Tag

Recommended Posts

I often want to play through a MovieClip once and then not loop again. Flash appears to have built-in behavior for this, because you can use the right-click menu on a running swf to uncheck "loop", and then the MovieClip will stop once it gets to its last frame. However, I cannot find any way to access this behavior using actionscript. The best I can do is listen for enterFrame events and check if currentFrame == totalFrames on each and every frame, then stop the clip and remove the listener on the final frame. Am I missing something? Is there a better way?

 

The reason I bring this up here is I've been using TweenMax as an alternative, like so:

 

clip.gotoAndStop(1);

TweenMax.to(clip, clip.totalFrames, { frame:clip.totalFrames, useFrames:true });

 

Will this produce exactly the same result as listening for enterFrame events and stopping the clip when currentFrame == totalFrames? Or is there some timing/delta-frames weirdness with FramePlugin and useFrames?

Link to comment
Share on other sites

I guess potentially, since I'm tweening from frame 1 to totalFrames instead of from frame 0 (which doesn't exist) to totalFrames, I should do:

 

clip.gotoAndStop(1);

TweenMax.to(clip, clip.totalFrames - 1, { frame:clip.totalFrames, useFrames:true });

 

This that right?

Link to comment
Share on other sites

Sure you can use TweenMax that way, but it's not necessary. All you need to do is go to the last frame of your MovieClip in the Flash IDE, add a blank keyframe, and add one simple line of ActionScript there: stop();

 

By the way, make sure you use the Linear.easeNone ease if you're going to use TweenMax. Otherwise, it'll apply a Quad.easeOut (the default) ease across the whole tween. That can be a very cool effect in certain cases, but if you want it to play linearly, use Linear.easeNone.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...