package{
import flash.display.Sprite;
import flash.display.*;
public class Main extends Sprite{
public function Main(){
var canvas:Shape = new Shape( );
addChild(canvas);
canvas.graphics.lineStyle(2, 0x0000FF);
curveThrough3Pts(canvas.graphics, 100, 100, 150, 50, 200, 100);
}// Adapted from Robert Penner's drawCurve3Pts( ) method
public function curveThrough3Pts (g:Graphics,startX:Number, startY:Number,
throughX:Number, throughY:Number,
endX:Number, endY:Number) {
var controlX:Number = (2 * throughX) - .5 * (startX + endX);
var controlY:Number = (2 * throughY) - .5 * (startY + endY);
g.moveTo(startX, startY);
g.curveTo(controlX, controlY, endX, endY);
}
}
}
|