rob_v_5712

rotation values and TimelineMax infinite repeat

Recommended Posts

I have a feeling that I'm just missing something here, but here it goes.

I have 2 circle of arrows one inside another.

I want one to rotate 15 degrees and wait 1 second then rotate another 15 degrees...

I want the to other to do the same but in the opposite direction...

var rotateTimeline = new TimelineMax( {useFrames:true,repeat:-1,repeatDelay:60} );

rotateTimeline.add('rotate',0)
.to(circle_1,15,{rotation:circle_1.rotation + 15},"rotate")
.to(circle_2,15,{rotation:circle_2.rotation - 15},"rotate");


What seems to happen is that it rotates 15 degrees then on the repeat, it goes back to the original position and rotates again.

Is there a way to just keep adding (or subtracting) 15 degrees each iteration?

 

Thanks

 

Share this post


Link to post
Share on other sites

When a tween or timeline repeats, it plays the same animation it did the first time.

The values that you pass into your tweens (rotation + 15) are not re-evaluated each time the animation plays (for efficiency).

 

You can force a tween or timeline to re-record the necessary values by using the invalidate() method.

 

Here is a basic implementation: 

http://codepen.io/GreenSock/pen/a36124de2c31ac6c2f140285a46e0b9a

 

Yes, its JavaScript but the syntax is identical in ActionScript. 

Share this post


Link to post
Share on other sites

Hey ya mate,

 

Don't really need Timeline Max for this. This should work for you too.

import com.greensock.TweenLite;

moveIt()
function moveIt()
{
	TweenLite.to(box1,1,{rotation:"+=15"})
	TweenLite.to(box2,1,{rotation:"-=15", delay:1, onComplete:function(){moveIt()}})
}

rotate.zip

  • Like 1

Share this post


Link to post
Share on other sites

Invalidate what exactly what I was after!  

 

Changed it to this and it worked like a charm :

rotateTimeline.add('rotate',0)
.to(circle_1,15,{rotation:"+=15"},"rotate")
.to(circle_2,15,{rotation:"-=15"},"rotate")
.call(rotateTimeline.invalidate,[],15);

Zync, Yours would work as well, but for my needs it needs to live in a timeline.  I appreciate the info.

 

Thanks

Share this post


Link to post
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.