math 2 - bezier curves

What is going on here is that an object (the blue circle) is moving between two points, but the movement is along a curve. This is a actually fair bit trickier than it looks. I was working on a different experiment when I realized there was no easy function in flash to accomplish this task. So I hit Google and found a solution. Here is the equation that calculates this movement.

B(t) = (1-t)^2*P0 + 2t(1-t)*P1 + t^2*P2

In this example the slider is controlling the value of t, while P0, P1, and P2 are the positions of the other circles.

While working on this I discovered another neat little property that is quite helpful. by using this:


The mouse cursor ignores that object. This is useful if you have two objects that overlap but the top one has no mouse interactions. It allows you easy access to the one below it. The alternative would be to use objectsUnderPoint to access it. This a lot simpler.

You can contact me on Twitter.


Browse All >