Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Dimitris

TweenMax onComplete - removeChild and null

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 post
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 post
Share on other sites

that's what i thought too, and i changed the logic so that it would clear the actual variable to null, instead of the reference "target"...

 

thanks

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.

×