Jump to content
Search Community

Tweening twice

ContraMuffin test
Moderator Tag

Recommended Posts

While using Greensock, I realized that an object can't be tweened more than 2 times.

I haven't tested the parameters of this, but I think that once I do a TweenMax.to tween, I can't tween that object anymore. It does not give me an error, but the tween simply does not happen.

An example of the TweenMax.to tween that I use is

TweenMax.to(object,1,{alpha:0}); 

and I'm trying to create a TweenMax.from tween like this

TweenMax.from(object,1,{alpha:0}); 

Is there a way to TweenMax.from tween that object again, and if so, how?

 

EDIT: OK I just tested, and that is what happens. The object no longer tweens whenever I use a TweenMax.to tween on it.

Link to comment
Share on other sites

I think there may be some kind of misunderstanding here. There is absolutely no limitation on how many times you can animate a particular object. It sounds like maybe you're trying to do a from() tween and defining the "from" values as identical to the current values. In other words, if alpha is currently 0, and you do a from(object, 1, {alpha:0}), nothing will animate because you're telling it to animate from alpha:0 to alpha:0 (no change). 

 

If you still need some help, please post a reduced test case that demonstrates the issue and we'll take a peek. Hit the "more reply options" below to get to a screen where you can attach a zipped FLA file. 

  • Like 1
Link to comment
Share on other sites

Ah, OK. That gives me some insight as to how to fix the issue. Should I use a "to" tween instead of a "from" tween and set the alpha to 100?

I just did, and I can see that the object CAN be tweened once again, but I now have another issue. Instead of performing a tween, the object just kind of pops to alpha:100. I have posted a a zipped .fla file of what I mean.

Link to comment
Share on other sites

Also, I understand you are probably just learning, but so you know our TimelineLite/Max tools allow you to not rely on delayedCall() or onComplete callbacks to build sequences.

 

Your code can be condensed to:

 

import com.greensock.*;

var tl:TimelineLite = new TimelineLite();

tl.from(sdf,1,{alpha:0})
  .to(sdf,1,{alpha:0})
  .to(sdf,1,{alpha:1})

The code above places 3 tweens in a timeline in succession.

http://greensock.com/timelinelite-as

Link to comment
Share on other sites

 

Also, I understand you are probably just learning, but so you know our TimelineLite/Max tools allow you to not rely on delayedCall() or onComplete callbacks to build sequences.

 

Your code can be condensed to:

 

import com.greensock.*;

var tl:TimelineLite = new TimelineLite();

tl.from(sdf,1,{alpha:0})
  .to(sdf,1,{alpha:0})
  .to(sdf,1,{alpha:1})

The code above places 3 tweens in a timeline in succession.

http://greensock.com/timelinelite-as

 

Ah, thank you! I did not know either of these things. And I probably would not have known them had you not told me.

Is it possible to run tweens at the same time instead of in sequence? For example, if I have 5 tweens, 1, 2, 3, 4, and 5, can I make them run in sequence except 2 and 3, which are run together? Also, can I place non-TimelineLite, normal AS3 commands into the timeline?

Link to comment
Share on other sites

Yeah, one of the many things that separates GSAP from other libraries is that you are not forced to do direct sequences, you can have overlaps and gaps (delays) in between tweens in a timeline. Its a very flexible system. 

 

The secret lies in the position parameter that lives in many TimelineLite methods like TimelineLite.to(), from(), staggerFrom() etc.

Definitely check out the docs on those methods

 

This is the best resource for understanding how to control the placement of tweens in a timeline. It has a video and a few interactive demos:

http://greensock.com/position-parameter

 

It uses the JavaScript version of GSAP, but the syntax in AS3 is identical. 

 

 

Also, a nice intro to TimelineLite()

http://greensock.com/sequence-video

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