Game Development Reference
In-Depth Information
In the dialog that pops up, give your project a name as follows:
And then click on Finish .
The following illustrates the code to draw your first sprite on the stage:
public function SpriteTest()
{
var s:Sprite = new Sprite();
s.graphics.beginFill(0xFF0000);
s.graphics.drawCircle(0, 0, 10);
s.graphics.endFill();
s.x = 25;
s.y = 25;
addChild(s);
}
The above is a simple example to create a sprite, which in this example is a red circle
at position x=25 and y=25.
Notice the call to addChild , which you must call in order for Flash to put it on the
stage. The main class SpriteTest , in this case, is a sprite and is added to the stage
automatically to the stage by Flash runtime.
Flash Builder automatically creates the main class with the same name as the name
we specify for the ActionScript project name. When you run the project, the program
execution starts in this main class's constructor.
 
Search WWH ::




Custom Search