# MouseEvent.CLICK - function not working

**URL:** <https://forum.kirupa.com/t/mouseevent-click-function-not-working/294255>\
**Category:** flash\
**Created:** [August 11, 2009, 2:26pm UTC](https://forum.kirupa.com/t/mouseevent-click-function-not-working/294255 "2009-08-11T14:26:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![333944](https://avatars.discourse-cdn.com/v4/letter/3/bbe5ce/32.png) [@333944](https://forum.kirupa.com/u/333944)\
**Post date:** [August 11, 2009, 2:26pm UTC](https://forum.kirupa.com/t/mouseevent-click-function-not-working/294255/1 "2009-08-11T14:26:38Z")

</div>

Hello,  
After parsing some XML to create a vertical project list I’d like to be able to click on the image/icon representing each project and be taken to the URL that’s been parsed in as well. Here’s the error I get when clicking the dynamically generated Movieclips:

[COLOR=“Red”]TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at NMD\_work\_fla::MainTimeline/itemClick()[/COLOR]

Below is the extracted code pieces related to the onClick function:

[SIZE=“2”][FONT=“Courier New”][COLOR=“DarkOrange”]//Sample XML:[/COLOR][/FONT][/SIZE]

```auto
<Projects>
	<project image="eRMA.png" link="http://www.a.com" description="..." />
</Projects>

```

[SIZE=“2”][FONT=“Courier New”][COLOR=“DarkOrange”]//Actionscript:[/COLOR][/FONT][/SIZE]

```php

//Assign the "link" value to the projectItem.link variable
projectItem.link = project.@link;

//Listen for the projectItem to be clicked on; after which call the itemClick function
projectItem.addEventListener(MouseEvent.CLICK, itemClick);

function itemClick(e:Event):void {
	//Get the item that dispatched the event
    var project:ProjectItem = e.target as ProjectItem;
        
    //Navigate to the URL that is assigned to the projectItem
    var urlRequest:URLRequest = new URLRequest(project.link);
    navigateToURL(urlRequest);

// **************Other options tried but still failed**************		
//var urlRequest:URLRequest = new URLRequest(e.target.link);
//navigateToURL(urlRequest);
			
//var item:ProjectItem = e.target as ProjectItem;
//			
//var loader = new Loader();
//loader.load(new URLRequest(item.link));
//addChild(loader);
	
//var urlRequest:URLRequest = new URLRequest(item.t);
//navigateToURL(urlRequest);
//			
//var targetURL:String = e.target.launchURL;
//var urlRequest:URLRequest = new URLRequest(targetURL);
//navigateToURL(urlRequest);
//var page:String = project.@link;
//trace(targetURL);
}

```

Please help, I’m not sure why I’m receiving the error and have tried various ways of launching the URL.  
Thanks, r/c
