AS3: How to add a tiled background


  1. Drag & Drop the image you want to tile on the stage
  2. Go to the Library, you’ll see that a Bitmap has been added, change the properties of it
  3. Activate the Advanced options if it isn’t shown
  4. Select both options in Linkage, and write a Class Name,  for example “Background”

From now on,  you’ll access your image as if it were a Class.

You can now make your image and tile it like so:

var backGroundSprite:Sprite = new Sprite();
//Background Class is actually the linkage to background.jpg in de Library
backGroundSprite.graphics.beginBitmapFill(new Background(0, 0));
backGroundSprite.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
backGroundSprite.graphics.endFill();
//Add and display on stage
addChild(backGroundSprite);
Advertisements

4 thoughts on “AS3: How to add a tiled background

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s