This is a simplest example,I hope this will help you to learn as3 and class concept, I love to code and want to share my code with other who want to learn as3 so i am starting a series or tutorials from basic to advanced level
package
{
import flash.display.Graphics;
import flash.display.MovieClip;
/**
* ...
* @author Jeet Chauhan
*/
public class Ball extends MovieClip
{
public function Ball()
{
draw()
}
private function draw():void
{
var g:Graphics = graphics;
g.beginFill(0xff0000, 1);
g.drawCircle(10, 10, 10);
}
}
}
In this example we create a class named Ball, which extends MovieClip class, In flash every object which have physical instance must extend MovieClip or Sprite Class,Sprite Class is super class of MovieClip,
then we get graphics property of MovieClip class
var g:Graphics = graphics;
and then set color to fill
g.beginFill(0xff0000, 1);
then draw a circle on it
g.drawCircle(10, 10, 10);
Like this:
Like Loading...
Related