TypeError: Error #1009: Cannot access a property or method of a null object reference
For some reason when ever I add the Mouse event listener I get the #1009 error and some stuff dissapears and the clicking function wont work, can anyone help?
package
{
import flash.display.*;
import flash.text.*;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.ui.*;
import flash.utils.*;
import flash.geom.*;
import flash.net.*;
import flash.media.Sound;
import flash.media.SoundTransform;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Platforms extends Sprite
{
var Floor = new floor();
var HighLightBox=new highLightBox();
var nyEditor:int = 0;
var nxEditor:int = 0;
var ExFloor=new exFloor();
var tFloor:exFloor = new exFloor ;
var bEditorClick:Boolean = false;
var arFloor = new Array();
var tmrBoxes:Timer = new Timer(35);
public function Platforms()
{
addChild(ExFloor);
addChild(Floor);
Floor.y = 500;
Floor.x = 300;
// constructor code
stage.addEventListener(MouseEvent.CLICK,Clicking);
tmrBoxes.addEventListener("timer",timerBoxes);
tmrBoxes.start();
}
public function TouchingGround(HeroGroundTouch:Sprite):Boolean
{
if (HeroGroundTouch.hitTestObject(Floor))
{
return true;
}
return false;
}
public function Clicking(e:MouseEvent):void
{
if (bEditorClick==false)
{
nxEditor = mouseX;
nyEditor = mouseY;
addChild(HighLightBox);
HighLightBox.x = mouseX;
HighLightBox.y = mouseY;
bEditorClick = true;
}
else
{
trace(" PlaceFloor("+nxEditor+","+nyEditor+","+(mouseX-nxEditor)+","+(mouseY-nyEditor)+");");
PlaceFloor(nxEditor,nyEditor,(mouseX-nxEditor),(mouseY-nyEditor));
removeChild(HighLightBox);
bEditorClick = false;
}
}
public function PlaceFloor(nx:int,ny:int,nWidth:int,nHeight:int):void
{
tFloor=new exFloor();
addChild(tFloor);
arFloor.push(tFloor);
tFloor.x = nx;
tFloor.y = ny;
tFloor.width = nWidth;
tFloor.height = nHeight;
}
function timerBoxes(eventArgs:TimerEvent)
{
HighLightBox.width = mouseX - HighLightBox.x;
HighLightBox.height = mouseY - HighLightBox.y;
}
}
}
