jakmagi
February 17th, 2010, 10:28 PM
Hullo..
A newbie here..and AS3..
Anyways..I was trying out AS3...when got this kinda error..
-----------------------------------------------------------------------
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at testCollision1_fla::MainTimeline/presscheck()
--------------------------------------------------------------
Anyways,...I created 2 sets of actions in 2 separate keyframes.
I just wanted to try playing in between the different frames..plus a few basic mouse-button interactions.
here's a look at the first actionscript../.
----------------------------------------------------------
stop();
moveblock.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
stage.addEventListener (Event.ENTER_FRAME, presscheck);
toKeyz.addEventListener(MouseEvent.MOUSE_UP, toNextKey);
function presscheck(event:Event):void
{
if(moveblock.hitTestPoint(mouseX, mouseY, true))
{
//trace("they");
checkTxt.text = "Help: " + "them";
}
}
function startMove(evt:MouseEvent):void
{
moveblock.startDrag();
}
function toNextKey(evt:MouseEvent):void
{
gotoAndPlay("keybord");
}
moveblock.addEventListener(MouseEvent.MOUSE_UP, stopMove);
function stopMove(evt:MouseEvent):void
{
moveblock.stopDrag();
checkTxt.text = "Help: block noticed";
if (bgwk.hitTestObject(moveblock))
{
trace("hrthr");
//moveblock.x = bgwk.x;
//moveblock.y = bgwk.y;
//rectangle
}
}
------------------------------------------------
...and here's the second action frame
-------------------------------------------------
stop();
btninviz.addEventListener(MouseEvent.MOUSE_UP, hidemouse);
btnvizy.addEventListener(MouseEvent.MOUSE_UP, showmouse);
//stage.addEventListener(Event.ENTER_FRAME, keepcsr);
toMose..addEventListener(MouseEvent.MOUSE_UP, back21);
function hidemouse(evt:MouseEvent):void
{
Mouse.hide();
}
function showmouse(evt:MouseEvent):void
{
Mouse.show();
}
function keepcsr(evt:Event):void
{
newcsr.x = mouseX;
newcsr.y = mouseY;
}
function back21 (evt:MouseEvent):void
{
gotoAndPlay("mousse");
}
-----------------------------------------------------------
here's me attached fla file..
http://www.mediafire.com/?nmzrxynzkfw
-------------------------------------------------
did skim through a few forums in this Error #1009 problem...am still confused...the only thing I noticed is that the error occurs when i add in the presscheck() and keepcsr() functions....which I suspect that it's related (I might have wrongly called/declared them) in the:
'stage.addEventListener(Event.ENTER_FRAME, keepcsr);', and
'stage.addEventListener(Event.ENTER_FRAME, presscheck);' lines..
Any ideas/suggestions to rectify them?
A newbie here..and AS3..
Anyways..I was trying out AS3...when got this kinda error..
-----------------------------------------------------------------------
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at testCollision1_fla::MainTimeline/presscheck()
--------------------------------------------------------------
Anyways,...I created 2 sets of actions in 2 separate keyframes.
I just wanted to try playing in between the different frames..plus a few basic mouse-button interactions.
here's a look at the first actionscript../.
----------------------------------------------------------
stop();
moveblock.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
stage.addEventListener (Event.ENTER_FRAME, presscheck);
toKeyz.addEventListener(MouseEvent.MOUSE_UP, toNextKey);
function presscheck(event:Event):void
{
if(moveblock.hitTestPoint(mouseX, mouseY, true))
{
//trace("they");
checkTxt.text = "Help: " + "them";
}
}
function startMove(evt:MouseEvent):void
{
moveblock.startDrag();
}
function toNextKey(evt:MouseEvent):void
{
gotoAndPlay("keybord");
}
moveblock.addEventListener(MouseEvent.MOUSE_UP, stopMove);
function stopMove(evt:MouseEvent):void
{
moveblock.stopDrag();
checkTxt.text = "Help: block noticed";
if (bgwk.hitTestObject(moveblock))
{
trace("hrthr");
//moveblock.x = bgwk.x;
//moveblock.y = bgwk.y;
//rectangle
}
}
------------------------------------------------
...and here's the second action frame
-------------------------------------------------
stop();
btninviz.addEventListener(MouseEvent.MOUSE_UP, hidemouse);
btnvizy.addEventListener(MouseEvent.MOUSE_UP, showmouse);
//stage.addEventListener(Event.ENTER_FRAME, keepcsr);
toMose..addEventListener(MouseEvent.MOUSE_UP, back21);
function hidemouse(evt:MouseEvent):void
{
Mouse.hide();
}
function showmouse(evt:MouseEvent):void
{
Mouse.show();
}
function keepcsr(evt:Event):void
{
newcsr.x = mouseX;
newcsr.y = mouseY;
}
function back21 (evt:MouseEvent):void
{
gotoAndPlay("mousse");
}
-----------------------------------------------------------
here's me attached fla file..
http://www.mediafire.com/?nmzrxynzkfw
-------------------------------------------------
did skim through a few forums in this Error #1009 problem...am still confused...the only thing I noticed is that the error occurs when i add in the presscheck() and keepcsr() functions....which I suspect that it's related (I might have wrongly called/declared them) in the:
'stage.addEventListener(Event.ENTER_FRAME, keepcsr);', and
'stage.addEventListener(Event.ENTER_FRAME, presscheck);' lines..
Any ideas/suggestions to rectify them?