Skip to content

Instantly share code, notes, and snippets.

@litvil
Forked from AlexHannigan/AS3 Shapes
Last active August 29, 2015 14:24
Show Gist options
  • Save litvil/148012236c6ab55a0545 to your computer and use it in GitHub Desktop.
Save litvil/148012236c6ab55a0545 to your computer and use it in GitHub Desktop.
package {
//import necessary classes
import flash.display.Sprite;
import flash.display.Graphics;
public class Circle extends Sprite {
private var canvas:Sprite = new Sprite();
private var gr:Graphics = canvas.graphics;
public function Circle() {
// constructor code
trace("drawing a Circle");
drawCircle();
drawSquare();
drawTriangle();
addChild(canvas);
}
//draw Circle method
private function drawCircle():void {
//drawing circle inside the graphics object
gr.lineStyle(6, 0x0000FF, 0.5);
gr.beginFill(0xFF0000, 0.5);
gr.drawCircle(200, 200, 50);
gr.endFill();
}
//draw Square method
private function drawSquare():void {
//drawing circle inside the graphics object
gr.lineStyle(6, 0x0000FF, 0.5);
gr.beginFill(0xFF0000, 0.5);
gr.drawRect(100, 100, 50, 50);
gr.endFill();
}
//draw Triangle method
private function drawTriangle():void {
//drawing circle inside the graphics object
gr.lineStyle(6, 0x0000FF, 0.5);
gr.beginFill(0xFF0000, 0.5);
gr.moveTo(0,0);
gr.lineTo(50,50);
gr.lineTo(0,50);
gr.lineTo(0,0);
gr.endFill();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment