Tuesday, May 06, 2008

ERR




Runtime errors in Flash 9.

I was stumped for quite a while this afternoon about the error:


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


I just turned out that I had redeclared a variable inside the new() constructor, like this:


class Zoomer extends Sprite {

private var box:Sprite;
private var dragleft:Sprite;

public function new() {
super();

var dragleft = new Sprite();
}

function mainMove (e:MouseEvent):Void {
dragleft.x = e.stageX;

}


That var shouldn't be in there, it should look like this:

class Zoomer extends Sprite {

private var box:Sprite;
private var dragleft:Sprite;

public function new() {
super();

dragleft = new Sprite();
}

function mainMove (e:MouseEvent):Void {
dragleft.x = e.stageX;

}