Jump to content
Search Community

Problem with Timeline.appendMultiple and TweenMax.allTo

teugene test
Moderator Tag

Recommended Posts

I have this problem I'm having when comes to appending a TweenMax.allTo with TimelineMax. The example code goes like this:

 

(m1, m2, m3 are MovieClips on the stage)

 

var timeline:TimelineMax = new TimelineMax();
timeline.appendMultiple([
TweenMax.allTo([m1, m2, m3], 1, {alpha: 0.2}),
TweenMax.to(m2, 1, {y: 50}),		
TweenMax.to(m3, 1, {y: 100})									 
]);

 

Although the tween executes correctly, a runtime error appears:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at com.greensock::TimelineLite/insert()

at com.greensock::TimelineLite/insertMultiple()

at com.greensock::TimelineLite/appendMultiple()

at Timeline_fla::MainTimeline/frame1()

 

Doing this returns the above error too:

 

timeline.appendMultiple([TweenMax.allTo([m1, m2, m3], 1, {alpha: 0.2})])

 

But I know that doing this will not return an error:

 

timeline.appendMultiple(TweenMax.allTo([m1, m2, m3], 1, {alpha: 0.2}));

 

The really strange part is I included a similar code in the first two examples in one part of my script and it executes perfectly without an error, but the same code in another part of the script returns the runtime error. There are no missing DisplayObjects and it was never removed from the stage. Am I missing something here?

Link to comment
Share on other sites

TweenMax.allTo() returns an array of tweens. But the way you structured your code causes that array to be nested inside the array you're passing to appendMultiple(). So it's kinda like appendMultiple( [[tween1, tween2], tween3, tween4] );

TimelineLite/Max expect the array to contain only TweenCore instances (like TweenLite, TweenMax, TimelineLite, TimelineMax instances) so when it comes across an array, it burps and says "DOH! This ain't no tweenable object. It's an array."

 

You can use concat() if you want to combine stuff like:

timeline.appendMultiple( TweenMax.allTo([m1, m2, m3], 1, {alpha: 0.2}).concat([TweenMax.to(m2, 1, {y: 50}),  TweenMax.to(m3, 1, {y: 100})] );

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