# Cannot access a property or method of a null object reference. Carl Looper 4 prez

**URL:** <https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference-carl-looper-4-prez/232526>\
**Category:** flash\
**Created:** [July 15, 2007, 3:36am UTC](https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference-carl-looper-4-prez/232526 "2007-07-15T03:36:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nobody](https://forum.kirupa.com/u/nobody)\
**Post date:** [July 15, 2007, 3:36am UTC](https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference-carl-looper-4-prez/232526/1 "2007-07-15T03:36:50Z")

</div>

Hi all,

I know there’s a few threads on this subject, but unfortunately those didn’t help me out too much. Also read the live docs on this and have gotten nowhere.

So here’s my code:

classes/RssRead.as

```auto

package classes {
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.display.StageScaleMode;
	
	import classes.graphics.*;
	
	public class RssRead extends Sprite {
		
		private var _bg:Background;
		
		public function RssRead() {
			init();
		}
		
		private function init():void {
			initStage();
			fireBackground();
		}
		
		private function initStage():void {
			stage.showDefaultContextMenu = false;
			stage.scaleMode = StageScaleMode.NO_SCALE;
		}
		
		private function fireBackground():void {
			_bg = new Background(0x333333);
			addChild(_bg);
		}

	}
	
}

```

classes/graphics/Background.as

```auto

package classes.graphics {
	
	import flash.display.Sprite;
	import flash.display.Graphics;
	
	public class Background extends Sprite {
		
		private var _color:uint;
		
		public function Background(c:uint) {
			_color = c;
			init();
		}
		
		private function init():void {
			drawBackground();
		}
		
		private function drawBackground():void {
			graphics.beginFill(_color);
			graphics.drawRect(0, 0, stage.height, stage.width);
			graphics.endFill();
		}
	}
}

```

errors:

```auto

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at classes.graphics::Background/::drawBackground()
	at classes.graphics::Background/::init()
	at classes.graphics::Background$iinit()
	at classes::RssRead/::fireBackground()
	at classes::RssRead/::init()
	at classes::RssRead$iinit()

```

I understand basically what the error is saying. I’m trying to apply changes to objects which are null. However I don’t really understand this issue because I’ve run code almost identical to this before without any issues. Any thoughts would be great, it’s frustrating trying to build code and getting stuck this early in the game every time :-/
