Jump to content
Search Community

TimelineMax.append offset argument problem

farmazone test
Moderator Tag

Recommended Posts

Hello

 

I want some objects to disapear:

 

var tl:TimelineMax=new TimelineMax();
for (var j:int = 0; j < 10; j++)
{
tl.append(TweenMax.to(item,0.1,{autoAlpha:0}));

}

 

it is ok but if I dont want to animate alpha and just sequentially hide items?

I thought something like this would do the job (the second argument of append method):

var tl:TimelineMax=new TimelineMax();
for (var j:int = 0; j < 10; j++)
{
tl.append(TweenMax.to(item,0,{autoAlpha:0}),0.1);

}

 

but it provides some strange results. why? It should add just 0.1 second delay between autoAlpha switches. Am I wrong or this is bug??

Link to comment
Share on other sites

hello,

 

first make sure you are using the latest version of the greensock engine. there have been some updates that deal with tweens of 0 second durations. don't know if those changes will effect your weirdness. your code looked pretty sound on first glance.

 

I got this to do what you want:

 

var timeline:TimelineMax = new TimelineMax()

for (var i:Number = 1; i	timeline.append(TweenMax.to(this["mc"+i], 0, {visible:false, delay:2}))
}

//i have 3 MovieClips on the stage mc1, mc2, mc3

 

the visible plugin automatically hides an object after its done tweening. really helpful.

 

also if you have many objects tweening the same properties to the same values, check out TweenMax.allTo().

 

if you have all your objects in an array like

 

var mcArray:Array = new Array(mc1, mc2, mc3, mc4, mc5) // you can also programmatically fill the array

 

you could just do

 

TweenMax.allTo(mcArray, 0, {visible:false}, .5);

 

or if this sequence was part of a larger TimelineLite/Max...

 

timeline.appendMultiple(TweenMax.allTo(mcArray, 0, {visible:false}, .5));

Link to comment
Share on other sites

One other thing (just to explain the result you were getting):

 

As indicated in the docs, zero-duration tweens that have no "delay" always render immediately unless you set immediateRender:false. It kinda makes sense when you think about it. I know you were putting the tween into a timeline that essentially delayed the starting time, but remember, the tween instance gets created BEFORE it is inserted into the timeline, so when the tween is created there's no way for it to know where you're going to put it, so it just says "hey, I've got a duration of 0 and no delay, so I better render immediately...unless immediateRender is false..."

 

So the solution is to simply add immediateRender:false to your tweens, like this:

 

var tl:TimelineMax=new TimelineMax();
for (var j:int = 0; j    tl.append(TweenMax.to(item, 0, {autoAlpha:0, immediateRender:false}), 0.1);
}

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