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…