Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Jakob Sternberg

[SOLVED] [TweenLite AS2] Pause by movieclip?

Recommended Posts

Hi

 

I'm tweening movieclips that get's added with attachMovieClip (simple particle system)

- For now i dont even use an array to keep track of the movieclips, i simply use onComplete to remove each movieclip when the tween is done.

 

Problem: I need to be able to pause these tweens, apparently i could create an array of the Tween instances ...but,.. is there another way? =P

 

I can loop through the movieclips, but how to pause their animation, without having their Tween instance reference, and without using pauseAll? (as i have other animations running elsewhere)

 

Thanks

Link to post
Share on other sites

Ok i think i found it, here's the basics if anyone needs it..

function pauseTweensIn(mc:MovieClip,doPause:Boolean){
   if(doPause !== false) doPause = true;
    for(var i:String in mc){
        if(typeof(mc[i]) == "movieclip"){
            var tweens = TweenMax.getTweensOf(mc[i])
            for(var t in tweens) tweens[t].paused = doPause
            }
        }
    }

// Usage Pause:
// pauseTweensIn(containerMc)

// Usage Resume:
// pauseTweensIn(containerMc,false)
Link to post
Share on other sites

Yeah, that solution would work, thanks for posting.

Not sure what constraints you are working under but an easy solution would be to place all the tweens in a TimelineLite and then call pause()/play() on the timeline when needed.

Link to post
Share on other sites
  • 1 month later...

Here's a AS3 version =) 

function pauseTweensIn(mc:MovieClip,doPause:Boolean = true):void{
 	for (var i:uint = 0; i < mc.numChildren; i++) {
		var tweens:Array = TweenMax.getTweensOf(mc.getChildAt(i))
		var c:uint = tweens.length
		while(c--) doPause ? tweens[c].pause() : tweens[c].resume();
		}   
	}
Link to post
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.

×