I have made a content where in one frame I have 10 movieclips(5 color pair) equally divided into two columns.I have added three event listener to the stage mousedown, mouseup, mouse move. I have drawn lines from one movieclip to another to match one column movie clip to another column same movie clip.. I added code to timeline but when I go to next frame or previous frame (where there are another acitvities) using next/prev button a warning is showing up :
Cannot access a property or method of a null object reference. at CL3_Sc_Pat12_SL05_fla::MainTimeline/mMove()
this waring is not showing for mousedown() mouseup().i have used same next and same previous button for 3 frames.and for frame jumping i numbered each frame as frame no 1,2,3.if frameno == 3 goto frame 2 if frameno== 2 goto frame 1 thus it works..frame jumping code is in 1st frame..
Here is my code :
stage.addEventListener(MouseEvent.MOUSE_DOWN, mDown);
stage.addEventListener(MouseEvent.MOUSE_UP, mUp);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mMove);
function mDown(event:MouseEvent):void
{
mouseHolding = true;
clickedX = mouseX;
clickedY = mouseY;
myDrawing.graphics.moveTo(mouseX, mouseY);
Line_draw.graphics.moveTo(mouseX, mouseY);
if (pencil.hitTestObject(box1)) //box of 1st column
{
trace("box1 value is: "+chk_val_1);
}
}
function mUp(MouseEvent):void
{
myDrawing.graphics.lineTo(mouseX, mouseY);
mouseHolding = false;
if (pencil.hitTestObject(hit_box1)) ////box of 2nd column
{
trace(boxes have same color);
Line_draw.graphics.lineTo(mouseX, mouseY);
}
}
function mMove(MouseEvent):void
{
if (mouseHolding && mouseY < 510 )
{
clearTemp();
Line_draw.graphics.lineTo(mouseX, mouseY);
}
}
function clearTemp():void
{
Line_draw.graphics.clear();
Line_draw.graphics.lineStyle(6,0x0066CC,1);
Line_draw.graphics.moveTo(clickedX, clickedY);
}
function nxt_click(event:MouseEvent)
{
gotoAndPlay(3);
}
function prev_click(event:MouseEvent)
{
gotoAndPlay(1);
}
My code is working perfect but I want to know why is this warning coming again and again ?