Jump to content
Search Community

TweenMax onComplete - removeChild and null

Dimitris test
Moderator Tag

Recommended Posts

I'm having some troubles with a function that gets called on the onComplete handler of TweenMax. Here's some code

 

// in some method
if (_gameOverScreen) {
TweenMax.to(_gameOverScreen, 0.55, {
			   alpha:0,
			   onComplete:removeSprite,
			   onCompleteParams:[_gameOverScreen, _gameContainer],
			   ease:Expo.easeOut
});
}

private function removeSprite(target:*, holder:*):void {
     holder.removeChild(target);
     target = null;
}

 

The problem is that the actual _gameOverScreen, which is passed to the parameters of the removeSprite method, doesn't get null.

 

Am I doing something wrong here?

 

Thanks in advance,

 

Dimitris

Link to comment
Share on other sites

You're setting target = null inside your function, but all that does is set the local variable "target" to null. It doesn't somehow null all other references in the application to that object. Think of "target" as just a pointer.

 

var original:String = "something";
var a:String = original;
var b:String = original;
a = null;
trace(a); //"null"
trace(; //"something"
trace(original); //"something"

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