ilteris kaplan blog

Archive of blog posts since 2005

April 5, 2008

Wiki

Flash Drawing API

#wiki

Flash Drawing API

LineStyle

You must set a linestyle using lineStyle();


var mcClip:MovieClip = this.createEmptyMovieClip("mcClip", this.getNextHighestDepth());
mcClip.lineStyle(0,0xFFFFFF,100);
mcClip.moveTo(100,100);
mcClip.lineTo(100,150);

the first parameter is the thickness of the line you want to draw. 0 or less will result in the hairline, any positive value will result in that point thickness. Second parameter is the color you want to draw. Third parameter is the opacity value of the line. If you want to create a line without stroke you have to set this to 0.

CurveTo

mcClip.curveTo(0,200,200,100); requires 4 parameters. first two are x,y value of the control point, and last two are x,y value of anchor point.



var mcClip:MovieClip = this.createEmptyMovieClip("mcClip", this.getNextHighestDepth());

var nControlY = 0;
setInterval(drawCurve, 50);

function drawCurve():Void {
mcClip.clear // clears everything on the stage.
mcClip.lineStyle(0,0xFFFFFF,100);
mcClip.moveTo(100,100);
mcClip.curveTol(50, nControlY, 100,0); // we only assign the second anchor point.
nControlY += .5;
updateAfterEvent();
}

Drawing Shapes

Any set of closed lines and/or curves forms a shape, shapes can be filled. Two basic types of shapes. rectangle and circle.

Continue Reading

Back to Archive