Jump to content
Search Community

draw animated bezier

negrito test
Moderator Tag

Recommended Posts

hello jack

 

i've got a question that sure pops up quite often but i couldn't find any post in the forum.

 

well, it's about animated beziers. let's suppose i create a simple tween with a bezier like that:

 

TweenMax.to(mc, 3, {bezier:[{x:100, y:200}, {x:0, y:400}], ease:Expo.easeOut});

 

now this will tween my movie clip along the bezier. that's quite nice but i would like to draw the bezier the movieclip has tweened through. and this while it is tweening. of course i could make an onUpdate and draw tiny lineTo chunks at every enterFrame but the line can become edgy if i tween fast and with a low number of frames.

 

is there any possibility draw the bezier (curve) while it is tweening?

 

basically it's this behaviour but with curves: http://www.edwardporter.com/flash/Comp1.mov

Link to comment
Share on other sites

Yeah, that behavior is easy with straight lines, but ones you introduce Beziers, it gets MUCH more complex. Flash's drawing API requires certain info to draw a curve and you'd essentially have to reconfigure the end point(s) and control point(s) on the fly and make the curve still follow precisely the same path throughout the tween. Not simple. So I don't have an easy answer for you. I may create a class eventually that'll make this easier, but in the mean time, the only thing I can think of is to use an onUpdate like you said. But you could wrap that functionality into a class of your own whose setter has logic in it that checks to see how far the new point is from the last one and if it's too far, it breaks it into smaller chunks and follows the Bezier curve accordingly. That way, you don't get the choppy parts when the tween goes too fast.

 

Hope that helps a little at least.

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