« FF3 breaks SWFAddress (sometimes) on OS X
» ASCB library (for AS2) - website defaced

AS3, Tech

Bug with TweenLite/Max: onComplete is fragile

06.26.08 | 6 Comments

I’ve just noticed a minor bug with TweenMax (and, I presume, TweenLite).

I set up a tween using TweenMax, and set an “onComplete” method. Then, after compiling, I noticed that there my method was throwing an NPE. However, instead of just throwing the exception once, it continued throwing it again and again: presumably, every frame. I presume the exception is stopping TweenLite (and therefore Max) in its tracks, and the tween is never removed.

Here is an excerpt from TweenLite (lines 407-410 in the version I have, 6.22) that I think is causing the problem:

if (this.vars.onComplete != null) {
this.vars.onComplete.apply(this.vars.onCompleteScope, this.vars.onCompleteParams);
}
removeTween(this);

Here’s the relevent parts of the stack trace:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at au.com.cfour.websites.c42008.view.pages.work::ProjectView/::handleExitTweenComplete()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at gs::TweenLite/complete()

(I got this same stack trace in my output panel hundreds of times before killing the SWF.)

I would suggest this simple fix:

try {
if (this.vars.onComplete != null) {
this.vars.onComplete.apply(this.vars.onCompleteScope, this.vars.onCompleteParams);
}
}
finally {
removeTween(this);
}

Should do the trick.

related

6 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:

:


« FF3 breaks SWFAddress (sometimes) on OS X
» ASCB library (for AS2) - website defaced
Close
E-mail It