# TypeError: Error #1009: Cannot access a property or method of a null object reference

**URL:** <https://forum.kirupa.com/t/typeerror-error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/289520>\
**Category:** Uncategorized\
**Created:** [June 1, 2009, 11:10am UTC](https://forum.kirupa.com/t/typeerror-error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/289520 "2009-06-01T11:10:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gopal2k6\_1983](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@gopal2k6\_1983](https://forum.kirupa.com/u/gopal2k6_1983)\
**Post date:** [June 1, 2009, 11:10am UTC](https://forum.kirupa.com/t/typeerror-error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/289520/1 "2009-06-01T11:10:53Z")

</div>

\*\*I am creating a some xml gallery but have a some issue

Error\*\*

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at gallery/init()  
at gallery$iinit()

**code:**

package  
{  
import flash.events.MouseEvent;  
import flash.display.MovieClip;  
import flash.display.Sprite;  
import flash.xml._;  
import flash.net.URLRequest;  
import flash.net.URLLoader;  
import flash.events._;  
import flash.text.\*;  
public class gallery extends Sprite  
{  
private var xml:XML;  
private var path:String=“photo.xml”;  
private var loader:URLLoader;  
private var mc:MovieClip;  
private var xmllist:XMLList;  
function gallery()  
{  
init();

```
	}
	public function init():void
	{
		createTextField();
		createBut();
		loader.addEventListener(Event.COMPLETE,xmlParse);
		
	}
	public function xmlParse(event):void
	{
		xml=new XML();
		xml.ignoreWhitespace=true;
		loader = new URLLoader(new URLRequest(path));
		xml=XML(loader.data);
		trace(xml);
		
	}
	
	private function createDynamicMc():void
	{
		mc = new MovieClip();
		mc.x=10;
		mc.y=10;
		addChild(mc);
	}
	private function createTextField():void
	{
		var text1:TextField = new TextField();
		text1.border=false;
		text1.x=300;
		text1.y=10;
		text1.width=240;
		text1.multiline=true;
		text1.height=50;
		addChild(text1);
		text1.text="demo";
	}
	private function createBut():void
	{
		var but1:flashBut= new flashBut();
		var text1:TextField= new TextField();
		text1.text="Next";
		but1.x=400;
		but1.y=350;
		addChild(but1);
		//but1.addChild(text1);
	}
}

```

}

\*\*xml \*\*

\<project\>  
\<img id=“123”\>img/1.jpg\</img\>  
\<img id=“123342343”\>img/2.jpg\</img\>  
\<img id=“123csdsdd3234”\>img/1.jpg\</img\>  
\<img id=“12332423v rwerweer”\>img/2.jpg\</img\>  
\<img id="123ewer werwr "\>img/1.jpg\</img\>  
\<img id="123rwer werr rerwer "\>img/2.jpg\</img\>  
\</project\>
