|
-
Tiled background question
I found some code online and it works fine. There's a bit of code that can be taken out and it still works. I just wanted to know why it's there.
Both examples below
//stage align/scale stuff
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//listen to see if the stage is resized
stage.addEventListener(Event.RESIZE, tileBG);
//create a sprite(movieclip without a timeline) called tile
var tile:Sprite;
//function to populate tiled bg onload and onResize
function tileBG(event:Event=null):void {
//create a reference to the old tile container
var oldTile:Sprite = tile;
//create a new tile container
tile = new Sprite();
//fill the container
tile.graphics.beginBitmapFill(new pattern(0, 0));
tile.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
tile.graphics.endFill();
//add the tile container to the display list
addChild(tile);
//get rid of the old container
if (oldTile != null && oldTile != tile) {
removeChild(oldTile);
}
}
tileBG();
Anyone share some light.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|