Game Development Reference
In-Depth Information
The following prints Hello World to the console:
trace("Hello World");
The following prints numbers from 0 to 99:
for ( var i:int=0; i<100; i++ )
trace("Value of i: " + i);
Embedding pictures
Before we continue onto mouse and keyboard events, let's look at how we can include
images as part of the project as well as read and use them in our program.
Let us embed two pictures, one for the background and another in place of a simple
red circle.
Flash Builder lets us simply drag a PNG or a JPG file into the project, but before we
drag it in, let us be organized about it and make a directory for all the assets. To do
this, you may right-click on the project folder and choose folder under new
menu item:
In the previous screenshot, you see that there are two PNG files (I personally like
.png because you can have transparency) under the rsrc folder.
Below is how you create a class that represents the image:
public class SpriteTest extends Sprite
{
[Embed(source="rsrc\\back.png")]
private var Back:Class;
private const HEIGHT:int = 100;
private const WIDTH:int = 100;
 
Search WWH ::




Custom Search