Jump to content


Seamless loop with bezier tween

Recommended Posts

The following code ALMOST works. The problem is that there isn't a smooth transition from one tween to the next. Cany anyone help?

import com.greensock.TweenLite; 
import com.greensock.easing.*;
import com.greensock.plugins.TweenPlugin; 
import com.greensock.plugins.*;
var dp3D:Array=[{x:0, y:0,z:1080},{x:1920, y:1080,z:0},{x:0, y:0,z:0},{x:1920, y:0,z:1080},{x:0, y:1080,z:0},{x:1920, y:1080,z:1080}]
function doBezier():void{
TweenLite.to(mc, 3, {bezierThrough:[{x:960, y:540,z:540}, dp3D[_bezierIndex]],onUpdate:tracePosition, ease:Linear.easeNone,onUpdateParams:[mc],onComplete:loopBezier}); 
function loopBezier(){
//if condition
function tracePosition(obj:DisplayObject):void {
trace("x: " + obj.x + " y:" + obj.y+ " z:" + obj.z);
Link to comment
Share on other sites

First, please make sure you are using the latest version of GSAP v12.

For v12 the BezierPlugin was completely re-written, enhanced and optimized:


From the v12 release notes:


Completely rewritten BezierPlugin with a vastly improved proprietary algorithm for drawing Beziers through an array of points/values naturally (even define a “curviness” value), a new “timeResolution” feature that ensures your object moves along the Bezier with the appropriate timing, and more accurate “autoRotate” (previously called orientToBezier) functionality. Plus you can pass in regular cubic or quadratic Bezier values if you prefer. Even use the static BezierPlugin.bezierThrough() method to have the plugin calculate the anchors and control points through the values you provide in either cubic or quadratic format so that you can, for example, draw the lines yourself using Flash’s graphics API or a <canvas> element. Ultimate control and freedom. Click on the “EXAMPLE” button next to “bezier” in the Plugin Explorer below to play with the new options interactively and see the sample code:



Docs: http://api.greensock.com/as/com/greensock/plugins/BezierPlugin.html


Although the new version is REALLY good at keeping the speed of the tween consistent regardless of how many points you have or how far they are spaced, it can't have any way of blending the speed of 1 tween with a new tween that is created.


Although creating your loop of many tweens is a fine approach, you will probably get the best results if you create 1 tween that has all the point data in it.


Let us know if you have success.

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