# Event from class

**URL:** https://forum.kirupa.com/t/event-from-class/271432
**Category:** flash
**Created:** [September 23, 2008, 3:46am UTC](https://forum.kirupa.com/t/event-from-class/271432 "2008-09-23T03:46:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![DrMaxMad](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@DrMaxMad](https://forum.kirupa.com/u/DrMaxMad)
#### Post date: [September 23, 2008, 3:46am UTC](https://forum.kirupa.com/t/event-from-class/271432/1 "2008-09-23T03:46:43Z")

</div>

Hi!..  
before asking question i would tell the people that i am new to OOPS… so i want to make a custom class and dispatch some events from that class…

this is custom class

> 

package  
{  
import flash.display.Sprite;  
import flash.events.MouseEvent;

```
public class SomeThing extends Sprite
{
	public function SomeThing ():void
	{
		init ();
	}
	private function init ():void
	{
		stage.addEventListener (MouseEvent.MOUSE_DOWN, doSome);
		stage.addEventListener (MouseEvent.MOUSE_UP, doSome);
		stage.addEventListener (MouseEvent.CLICK, doSome);
		stage.addEventListener (MouseEvent.DOUBLE_CLICK, doSome);
	}
	
	private function doSome(eve:MouseEvent):void
	{
		trace (eve.type);
	}
}

```

}

when i instantiate it like this… assuming that the class is in same directory as the .fla…

> 

var sone:SomeThing = new SomeThing()

it gives me small error like this…

> 

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at com.drmax.ui::SomeThing/init()  
at com.drmax.ui::SomeThing()  
at Untitled\_fla::MainTimeline/frame1()

can some one tell me why its happening and how can i add events on stage from a class…
