1
votes

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 ?

1
Could you share your project ( .FLA ) ?akmozo
i am new .would u please share me how to upload my fla file?i could not find any optionsUSERRR5
You can try filedropper.com (without account creation), mediafire.com, dropbox.com ...akmozo
filehosting.org/file/details/473140/CL3_Sc_Pat12_SL05.fla this is the link to download fla fileUSERRR5
For plugins, I think that's better to remove the download link because of copyright issue.akmozo

1 Answers

1
votes

You need to draw arrows (lines) just in your "anim4" frame so outside this frame you have to disable this function and remove all stage listener created for that, so you can do like this :

function nxt_click(event:MouseEvent)
{   
    if(){
        // your other instructions
    }
    // your other instructions

    else if (my_frame == 4)
    {
        stage.removeEventListener(MouseEvent.MOUSE_DOWN, mDown);
        stage.removeEventListener(MouseEvent.MOUSE_UP, mUp);
        stage.removeEventListener(MouseEvent.MOUSE_MOVE, mMove); 
        gotoAndPlay("anim5");       
    }
}

And you should do the same thing when exiting the "anim4" frame by pressing the previous button.

Hope that can help.