Tiled Background in AS3

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.

Any help would be awesome.

Thanks!

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


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();	
		};
	};
};

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!

Post your project. : )

Sent you a private message. Thanks man :beer: