Created
October 23, 2012 11:01
-
-
Save AlexHannigan/3938174 to your computer and use it in GitHub Desktop.
Triangle, square and circle drawn in AS3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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