Jump to content
Search Community

function to killChildTweensOf of all children and their children and their children... etc?

martis test
Moderator Tag

Recommended Posts

Hi guys,

 

I have a scenario where I have many MovieClips with many children, that have children, etc...

 

 

I am looking for a way (most likely a function) that I can pass a MovieClip to and have it killChildTweensOf of all its children, and their children and their children etc....

 

I know killAll exists, but I have other tweens happening that I want to continue.

 

Has anyone created a function that could loop through a MC and all its children, and their children and killChildTweensOf until there are no more children? :)

 

Thanks in advance!

 

Link to comment
Share on other sites

To be clear...

 

I have MC A, B, C

 

C is inside of B which is inside of A

 

If I do TweenMax.killChildTweensOf(A, true) it should only stop tweens for B, not C? Or will it go down the nested display list and kill B and C?

 

If not, I wrote this little function which seems to work

// Loop through and kill tweens of all children
		private function killChildTweensOf( mc : *) : void{
			
			if(mc is DisplayObjectContainer) {
				
				TweenMax.killChildTweensOf(mc, true);
				
				for(var i:uint = 0; i < mc.numChildren; i++) {
					var child : * = mc.getChildAt(i);
					
						killChildTweensOf(child);
					
				}
				
			}
		}
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...