Jump to content
Search Community

tweenlite doesnt complain

tean test
Moderator Tag

Recommended Posts

i have 3 moviclips on the stage named q0,q1,q2.

 

var arr:Array = [q0,q1,q2];

 

for (var k:int = 0; k < 5; k++) {

 

trace(arr[k]);

 

TweenLite.to( arr[k], 1, { y: 100 });

 

}

 

last 2 will be undefined but it wont throw an error...

this is meant to be?

Link to comment
Share on other sites

sure, it cant be any simpler...

 

ofcourse, maybe i am missing something :mrgreen:

 

 

even if i write it like this i get nothing:

 

import gs.TweenLite;

var arr:Array = [q0,q1,q2];

for (var k:int = 0; k < 5; k++) {
try {
	TweenLite.to( arr[k], 1, { y: 100 });
} catch (e:Error) {
	trace(e);
}
}

Link to comment
Share on other sites

Yep, as expected, I got an error the first time the tween tried to render:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock::TweenLite/init()
at com.greensock::TweenLite/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()

 

The constructor shouldn't throw an error anyway because you could conceivably create a tween with a null target if you wanted to just use an onComplete or something. Not that I'd recommend it, but it's certainly possible.

 

By the way, I'd highly recommend upgrading to v11 by the way - looks like you're still using the old v10 or before.

Link to comment
Share on other sites

thank you for this, you are right, i thought something was wrong with my compiler :lol:

 

btw, greensock could have done it like this:

 

if ($target == null) {
  throw new Error("damn, these words are expensive :)");
  return
}

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