
MovieClip._droptarget Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
649
If any of curveTo()’s arguments are missing, the operation fails silently and the position of
the drawing pen remains unchanged. For a description of the drawing pen, see the Discus-
sion under MovieClip.moveTo().
For a primer on Bézier curve mathematics and programming, see:
http://www.ipm.sci-nnov.ru/~demidov/VRML/Splines/Intro/Bezier.htm
Example
Sometimes it is more convenient to specify three points on a curve rather than two anchor
points and a control point. The following code adds a custom curveThrough3Pts() method
to all movie clips; the method accepts three points as arguments and draws a quadratic
curve that passes through them. The second point is assumed to be halfway along the
curve, in time (t = .5):
// Adapted from Robert Penner's drawCurve3Pts() method
MovieClip.prototype.curveThrough3Pts =
function (startX, startY, throughX, throughY, endX, endY) {
var controlX = (2 * throughX) - .5 * (startX + endX);
var controlY = (2 * throughY) - .5 * (startY + endY);
this.moveTo(startX, startY);
this.curveTo(controlX, controlY, endX, endY);
};
// Usage
this.createEmptyMovieClip("drawing_mc", 1);
drawing_mc.lineStyle(1, 0xFF0000);
drawing_mc.curveThrough3Pts(100, 100, 150, 50, 200, 100);
See Also
MovieClip.beginFill()