# AS3 Bitmap animation

**URL:** https://forum.kirupa.com/t/as3-bitmap-animation/209587
**Category:** flash
**Created:** [December 10, 2006, 4:15pm UTC](https://forum.kirupa.com/t/as3-bitmap-animation/209587 "2006-12-10T16:15:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pi3rc3](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@pi3rc3](https://forum.kirupa.com/u/pi3rc3)
#### Post date: [December 10, 2006, 4:15pm UTC](https://forum.kirupa.com/t/as3-bitmap-animation/209587/1 "2006-12-10T16:15:31Z")

</div>

im new to as3 and am working on a little game and have run into some trouble. basicly im trying to set a bitmap to follow an object i have.  
heres some code…

```auto

		override public function paint():void{
			super.paint();

			if(imageLoaded=false){
				trace("loading image...");
				
				loadImage();
				imageLoaded=true;
				
				trace("image loaded.");
			}
			
			if(imageLoaded=true){
				mBit.x = super.px;
				mBit.y = super.py;
			}
			
			
		}
		
		public function loadImage():void{
			mData = new BitmapData(game._loader.height,game._loader.width,true,0xffffff);
			mBit = new Bitmap(mData);
			
			mData.draw(game._loader);
			
			game.addChild(mBit);
		}

```

all the stuff in the loadImage() used to be where loadImage is called and it would run but would draw the image over and over leaving a trail so i moved it so it would only draw once but now it wont even work, tells me “Error #1009: Cannot access a property or method of a null object reference.” which reffers to “mBit.x = super.px;”.

any help?
