# Calling mouseEvent from within a different function

**URL:** <https://forum.kirupa.com/t/calling-mouseevent-from-within-a-different-function/326894>\
**Category:** Uncategorized\
**Created:** [January 19, 2012, 8:49pm UTC](https://forum.kirupa.com/t/calling-mouseevent-from-within-a-different-function/326894 "2012-01-19T20:49:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imhappe](https://avatars.discourse-cdn.com/v4/letter/i/da6949/32.png) [@imhappe](https://forum.kirupa.com/u/imhappe)\
**Post date:** [January 19, 2012, 8:49pm UTC](https://forum.kirupa.com/t/calling-mouseevent-from-within-a-different-function/326894/1 "2012-01-19T20:49:55Z")

</div>

Hi -

I’ve got a mouse event that I need to call from a function within the mouse event function, but I’m getting an error. Here’s the code I’m using:

```auto
[FONT=courier new]function onTrButtonClick(me:MouseEvent):void[/FONT]
[FONT=courier new]{[/FONT]
[FONT=courier new]trace ("Do something");[/FONT]
[FONT=courier new]//more stuff in here[/FONT]
[FONT=courier new]//function for back button click[/FONT]
[FONT=courier new]//NOTE: back button only gets built during this function, so i can't move this outside onTrButtonclick[/FONT]
[FONT=courier new]function onbackButtonClick(me:MouseEvent):void[/FONT]
[FONT=courier new]{[/FONT]
[FONT=courier new]trace("back button clicked")[/FONT]
[FONT=courier new]onTrButtonClick(null);[/FONT]
[FONT=courier new]}[/FONT]
[FONT=courier new]}[/FONT]

```

This is returning the following error:  
TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at troubleshooting\_fla::MainTimeline/onTrButtonClick()  
at Function/\<anonymous\>()

What am I doing wrong?

Thanks!  
Miriam
