/3/ drawing api

// Create a clip to draw in
this.createEmptyMovieClip("drawing_mc", 2);

// Define a stroke style (thickness, rgb, alpha):
drawing_mc.lineStyle(1, 0x000000, 100);

// Draw a black line to x:100, y:0
drawing_mc.lineTo(100, 0);

// Draw a thick red line to x:200, y:0
drawing_mc.lineStyle(20, 0xFF0000, 100);
drawing_mc.lineTo(200, 0);

// Draw a curve (quadratic bezier) from there to x:300, y:0
drawing_mc.curveTo(250, -100, 300, 0);

// ===========Clear the drawing=============
drawing_mc.clear();

// Now let's draw a filled triangle...

// Position the drawing pen.
drawing_mc.moveTo(100, 100);

// Start the shape (rgb, alpha).
drawing_mc.beginFill(0xFF0000, 100);

// Draw the lines of the triangle.
drawing_mc.lineTo(200, 100);  // Right 100 pixels.
drawing_mc.lineTo(150, 200);  // Left 50 pixels, down 100 pixels.
drawing_mc.lineTo(100, 100);  // Back to start: left 50 pixels, up 100 pixels.

// End the shape.
drawing_mc.endFill();

// ============Clear the drawing again=============
drawing_mc.clear();

// Now let's draw the same triangle but with a gradient fill.

drawing_mc.lineStyle(1, 0xFF0000);
drawing_mc.moveTo(0, -50);

// Set gradient parameters.
var fillType = "radial";
var colors = [0xFF0000, 0x00FF00, 0x0000FF];
var alphas = [100, 100, 100];
var ratios = [0, 127, 255];
var matrix = { matrixType:"box", x:-50, y:-35, w:100, h:100, r:toRadians(0) };
// Rotation wants radians so we give it radians.
function toRadians (deg) {
  return deg * Math.PI/180;
}

// Start the shape.
drawing_mc.beginGradientFill(fillType, colors, alphas, ratios, matrix);
// Draw the lines of the triangle.
drawing_mc.lineTo(50, 50);
drawing_mc.lineTo(-50, 50);
drawing_mc.lineTo(0, -50);
// End the shape.
drawing_mc.endFill();