Jump to content


BezierPlugin.parseBeziers method missing?

Recommended Posts

Hi and welcome to the GreenSock forums, 


I'm not terribly sure what was going on in the codebase back in 2009 (before my time).


The latest version of GSAP has a private _parseBezierData() method. *note the _underscore which means it's private and really only meant for internal use and not something we support, but you are welcome to see if that works for you. It is commented quite well.



Link to comment
Share on other sites

Carl, thank-you and thank-you for such a quick reply. I felt sorry to see the Flash forum was now in archive status.


I found the private _parseBezierData function earlier. Odd that it's not actually marked as private, despite the leading _ in the method name.


When I tried it, I realised that it requires a type argument and am not sure what are valid types. I figured "cubic" and "soft" from looking inside the function but wondered what the default was as I'm using default bezier in my test. Also what is the third argument - prepend - for? For some reason I failed to get it to work before I posted here, but I will try again tomorrow!


My other option might be to switch to a greensock lib from 2010 (2.222), but not sure the rest of my project which uses MotionPath will still work at this point.

Link to comment
Share on other sites

Are you looking for this?:



We completely rewrote the entire BezierPlugin at some point and it's orders of magnitude better in various ways - I wonder if you're using an old one from before that rewrite. I believe the old one used "soft" for everything. I think "prepend" optionally lets you pass an object in that should be placed first in the list of points (unlikely you'd need that). 

Link to comment
Share on other sites



thanks for the tip. That works great!


Now, I wonder how to find the length of the curve? I see that when the tween is started inside the Plugin it creates a _length property. But this cannot be accessed at any other time - like when using bezierThrough method. Is there a way around this? I need to have consistent speeds whilst my sprite travels along different paths, straight or curved.


I guess it would have been nice to have a bezier curve in the MotionPath library, so that it had the same functionality as straight lines - like the length. I presume all work has stopped on the Flash version of Greensock, now.... 




Link to comment
Share on other sites

I'm trying to call the _parseLengthData function like this (based on the example you showed me). At the same time as I draw the curve, I create a data objects with the structure of Segments (a,b,c,d). I had to edit on line in the BezierPlugin _addCubicLengths function  to make it accept an Object, not a Segment class type (bez:Object) in the local variable.


It runs without error but I get a NaN(s) for the returned length and lengths properties.


var xArray=[]

var yArray=[]
 g.moveTo(bx[0].a, by[0].a);
 for (var i:int = 0; i < bx.length; i++) {
var xobj = {a: bx.a, b: bx.b, c: bx.c, d:bx.d}
var yobj = {a: by.a, b: by.b, c: by.c, d:by.d}
    g.curveTo(bx.b, by.b, bx.c, by.c);
var bzData=BezierPlugin._parseLengthData({x:xArray, y:yArray})
trace("Boing", bzData.length, bzData.lengths)
Link to comment
Share on other sites

Sorry, but we never intended to expose methods like that or commit to BezierPlugin supporting things like getting the length, etc. We have limited resources to dedicate to our free forums and aren't in a position to start supporting this type of functionality and consulting. I wish I had an easy answer for you. If you'd like to contact us about our consulting services, we can certainly explore that with you. 

Link to comment
Share on other sites

Ok, no worries – thank-you for your help so far! I'll look into it and see if there's another way without length.



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