0

so I'm still fairly new to AS3 and I'm getting my head around the errors and stuff and I'm trying to figure out why this is not working how it should, the function still executes but it leaves an error on my console. Here is my code:

import flash.events.MouseEvent;
import flash.display.MovieClip;

stop();

var activeHitArray:Array = new Array(word_select_box);
var activeDropArray:Array = new Array(answer1_word, answer2_word, answer3_word);
var hitPositionsArray: Array = new Array();

for (var numi:int = 0; numi < activeDropArray.length; numi++) {
activeDropArray[numi].buttonMode = true;
activeDropArray[numi].addEventListener(MouseEvent.MOUSE_DOWN, mousedown1);
activeDropArray[numi].addEventListener(MouseEvent.MOUSE_UP, mouseup1);

     hitPositionsArray.push({xPos:activeDropArray[numi].x,        yPos:activeDropArray[numi].y});

}

function mousedown1(event:MouseEvent):void {
event.currentTarget.startDrag();
setChildIndex(MovieClip(event.currentTarget), numChildren - 1);
}

function mouseup1(event:MouseEvent):void {
var dropindex1:int = activeDropArray.indexOf(event.currentTarget);
var target:MovieClip = event.currentTarget as MovieClip;
target.stopDrag();

if(target.hitTestObject(activeDropArray[dropindex1])){
           // target.x = activeHitArray[dropindex1].x;
            //target.y = activeHitArray[dropindex1].y;

            if(answer1_word.hitTestObject(word_select_box)){
                   gotoAndStop("6");
            }

} else {
        target.x = hitPositionsArray[dropindex1].xPos;
        target.y = hitPositionsArray[dropindex1].yPos;
}


}

And the Error I'm getting through is:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
  at game_flv_fla::MainTimeline/frame6()
  at flash.display::MovieClip/gotoAndStop()
  at game_flv_fla::MainTimeline/mouseup1()

The only thing I can think of is that it is something to do with the gotoAndPlay() because when I place a trace into it's place I get no errors.

4

1 に答える 1