var triangle:Shape;
drawTriangle(0, 10, 100, 0xFF0000);
function drawTriangle(x:Number, y:Number, height:Number, color:uint){
triangle = new Shape;
triangle.graphics.beginFill(color);
triangle.graphics.moveTo(height/2, y);
triangle.graphics.lineTo(height, height+y);
triangle.graphics.lineTo(x, height+y);
triangle.graphics.lineTo(height/2, y);
addChild(triangle);
}
Welcome to my actionscript snippet library!
Actionscript Snips is a small repository of actionscript code that aims to save developers and designers time when developing a website.
Showing posts with label Graphics. Show all posts
Showing posts with label Graphics. Show all posts
Draw A Triangle
Draw A Circle
var circle:Shape;
drawCircle(100, 100, 75, 0xFF0000);
function drawCircle(x:Number, y:Number, radius:Number, color:uint){
circle = new Shape;
circle.graphics.beginFill(color);
circle.graphics.drawCircle(x, y, radius);
circle.graphics.endFill();
addChild(circle);
}
Draw A Rectangle
var rectangle:Shape;
drawRectangle(0, 0, 200, 200, 0x0000FF); //Draws a rectangle at the origin
function drawRectangle(x:Number, y:Number, width:Number, height:Number, color:uint){
rectangle = new Shape;
rectangle.graphics.beginFill(color);
rectangle.graphics.drawRect(x, y, width, height);
rectangle.graphics.endFill();
addChild(rectangle);
}