# Tiled bg image enlarging in AS3!

**URL:** <https://forum.kirupa.com/t/tiled-bg-image-enlarging-in-as3/312268>\
**Category:** flash\
**Created:** [July 29, 2010, 11:55am UTC](https://forum.kirupa.com/t/tiled-bg-image-enlarging-in-as3/312268 "2010-07-29T11:55:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![v1810](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@v1810](https://forum.kirupa.com/u/v1810)\
**Post date:** [July 29, 2010, 11:55am UTC](https://forum.kirupa.com/t/tiled-bg-image-enlarging-in-as3/312268/1 "2010-07-29T11:55:25Z")

</div>

I am creating screensavers in Flash and I am having an issue with my tile auto enlarging…the import size in the library is only 100 x 78 pixels. After I publish and text the movie the tile is scaling out…no idea why.

Here is the tiling code:

[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]var backGroundSprite:Sprite = new Sprite();[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backGroundSprite.graphics.beginBitmapFill(new Background\_01(0, 0));[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backGroundSprite.graphics.drawRect(0, 0, Capabilities.screenResolutionX, Capabilities.screenResolutionY);[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]/_backGroundSprite.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);_/[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backGroundSprite.graphics.endFill();[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]addChild(backGroundSprite);[/FONT][/COLOR][/COLOR][/SIZE][/FONT]

[SIZE=2][COLOR=black][COLOR=navy][FONT=Arial][COLOR=black]Here is the code for scaling the movie:[/COLOR] [/FONT][/COLOR][/COLOR][/SIZE]

[SIZE=2][COLOR=black][COLOR=navy][FONT=Arial][FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]function init() [/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]{[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]stage.align=StageAlign.TOP\_LEFT;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]stage.scaleMode=StageScaleMode.NO\_SCALE;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]

[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]stage.addEventListener(Event.RESIZE, updateSize);[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]stage.dispatchEvent(new Event(Event.RESIZE));[/FONT][/COLOR][/COLOR][/SIZE][/FONT]

[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backgroundRectangle.x = 0;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backgroundRectangle.y = 0;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]}[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]init();[/FONT][/COLOR][/COLOR][/SIZE][/FONT]

[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]function updateSize(e:Event) [/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]{[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]//set background’s size[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backgroundRectangle.width = stage.stageWidth;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]backgroundRectangle.height = stage.stageHeight;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]

[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]//center content[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]centerRectangle.x = stage.stageWidth/2 - centerRectangle.width/2;[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]/_centerRectangle.y = stage.stageHeight/2 - centerRectangle.height/2;_/[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[FONT=Arial][SIZE=2][COLOR=navy][COLOR=navy][FONT=Arial]}[/FONT][/COLOR][/COLOR][/SIZE][/FONT]  
[/FONT][/COLOR][/COLOR][/SIZE]
