# Tiled Background in AS3

**URL:** <https://forum.kirupa.com/t/tiled-background-in-as3/264732>\
**Category:** flash\
**Created:** [June 29, 2008, 8:13pm UTC](https://forum.kirupa.com/t/tiled-background-in-as3/264732 "2008-06-29T20:13:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![beneath\_the\_sky](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/beneath_the_sky/32/506_2.png) [@beneath\_the\_sky](https://forum.kirupa.com/u/beneath_the_sky)\
**Post date:** [June 29, 2008, 8:13pm UTC](https://forum.kirupa.com/t/tiled-background-in-as3/264732/1 "2008-06-29T20:13:07Z")

</div>

I’ve been transitioning to AS3 and am looking for just a simple solution to tile a 8px x 8px movie clip across the stage.

I came across this post from a while back but doesn’t seem to work the same when using in a class file. When I change the linkage properties, I’m unable to only put in a Class name because it’s asking for a base class.

> **[ActionScript 3 Tip of the Day - Page 20](https://www.kirupa.com/forum/showthread.php?p=2030073&highlight=tiled+background#post2030073)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

Any help would be awesome.

Thanks!

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 29, 2008, 8:57pm UTC](https://forum.kirupa.com/t/tiled-background-in-as3/264732/2 "2008-06-29T20:57:56Z")

</div>

‘tile’ is a bitmap exported as ‘tile’ in my library;

```auto

package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.display.Bitmap;
	
	public class bmpfill extends Sprite {
		
		private var bg:Sprite;
		
		public function bmpfill():void {
			bg = new Sprite();
			addChild(bg);
			stage.scaleMode=StageScaleMode.NO_SCALE;
			stage.align=StageAlign.TOP_LEFT;
			stage.addEventListener(Event.RESIZE, reDrawBG);
		};
		
		private function reDrawBG(e:Event):void {
			bg.graphics.clear();
			bg.graphics.beginBitmapFill(new tile(1,1));
			bg.graphics.moveTo(0, 0);
			bg.graphics.lineTo(e.target.stage.stageWidth,0);
			bg.graphics.lineTo(e.target.stage.stageWidth, e.target.stage.stageHeight);
			bg.graphics.lineTo(0, e.target.stage.stageHeight);
			bg.graphics.lineTo(0, 0);
			bg.graphics.endFill();	
		};
	};
};

```

---

<div class="post-metadata">

**Author:** ![beneath\_the\_sky](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/beneath_the_sky/32/506_2.png) [@beneath\_the\_sky](https://forum.kirupa.com/u/beneath_the_sky)\
**Post date:** [June 29, 2008, 10:18pm UTC](https://forum.kirupa.com/t/tiled-background-in-as3/264732/3 "2008-06-29T22:18:39Z")

</div>

Thanks very much for posting that code.

I got it to work when I put it in a separate class file and compiled from a blank fla with only the ‘tile’ in the library.

For some reason I can’t get it to work in my working file. I don’t get any errors after changing a few names but it’s not displaying the tile. Guess I’ll have to keep messing with it. I appreciate it, sekasi!

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 29, 2008, 10:36pm UTC](https://forum.kirupa.com/t/tiled-background-in-as3/264732/4 "2008-06-29T22:36:53Z")

</div>

Post your project. : )

---

<div class="post-metadata">

**Author:** ![beneath\_the\_sky](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/beneath_the_sky/32/506_2.png) [@beneath\_the\_sky](https://forum.kirupa.com/u/beneath_the_sky)\
**Post date:** [June 29, 2008, 11:23pm UTC](https://forum.kirupa.com/t/tiled-background-in-as3/264732/5 "2008-06-29T23:23:51Z")

</div>

Sent you a private message. Thanks man 🍺
