Jump to content
Search Community

Simple remove child after tween

lostatoll test
Moderator Tag

Recommended Posts

I've been wondering this for a little bit, and it might not even fall into the scope of tweenlite, but I know there is a better way to achieve it, that I don't know.


All I want to do is remove a display object after a tween, without having to have multiple functions.

private function removeBG():void{

		TweenLite.to(_bg, 1, {alpha:0, ease:Quad.easeInOut, onComplete:remove});


	private function remove():void {

		_bg = null;



It would be kind of nice to do something like {alpha:1, endKill:true} or anything just to keep it on one line.. thanks for any tips.

Link to comment
Share on other sites

You could do something like this:


TweenLite.to(_bg, 1, {alpha:0, ease:Quad.easeInOut, onComplete:this.removeChild, onCompleteParams:[_bg]});


Keep in mind that autoAlpha could be used in place of alpha and then it'd automatically set the "visible" property to false when alpha is 0, thus improving performance in virtually the same way as removing the child altogether (at least in terms of rendering performance).

Link to comment
Share on other sites

  • 2 months later...

Apologies if this is seen to be jumping on the end of someone else's post but my question is very similar to the original poster so though it'd be OK to do so, all I 'm trying to work out is how do I now fire a second function? What I'm trying to do is tween a MovieClip back to zero, then remove the Clip (exactly what has been done in the original post...


but now I want to fire another function that does something else.)


I'm a little stumped :?

Link to comment
Share on other sites

If you want to trigger multiple functions at the end of your tween, you have two options:


1) Write a separate function that calls your two functions like:


TweenLite.to(mc, 1, {x:100, onComplete:doStuff});
function doStuff():void {




2) If you're using TweenMax, you can add multiple event listeners for the COMPLETE event.

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