[AS3]Error #1009 , null object in my array (movie clip)

274 Views Asked by At

I've got the Error #1009 in my project and it pisses me off.

My problem in null object reference. Especially in array. I declare movie clip into an array. But the result is null. Name of my movie clip (instance) its match.

Here is my full code:

package  {

import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.trace.Trace;
import fl.transitions.Tween;
import fl.transitions.easing.*;

public class Level extends MovieClip {


    public var dragArray:Array = [obj1, obj2;
    public var obstacleArray:Array = [obs_obj];
    public var matchArray:Array = [obj1target, obj2target];

    public var currentClip:MovieClip;
    public var startX:Number;
    public var startY:Number;



    public function Level()  {
        // constructor code

        trace(dragArray);
        var tween:Tween = new Tween (tutorial,'x',Bounce.easeOut,918.9,720,0.7,true)
        var dragGame:DragGame = new DragGame(stage, dragArray, matchArray);
        dragGame.addEventListener(DragGame.MATCH_MADE, onMatch);
        dragGame.addEventListener(DragGame.NO_MATCH, onFlub);
        dragGame.addEventListener(DragGame.ALL_DONE, onDone);


        function onMatch(event:Event):void {
            //var matchSound:Sound = new MatchSound();
            //matchSound.play();
            trace("Match");
        }
        function onFlub(event:Event):void {
            //var flubSound:Sound = new FlubSound();
            //flubSound.play();
            trace("Flub");
        }
        function onDone(event:Event):void {

        }   
     }
  }

}

I can't call DragGame(), I'm using trace in my array, it only shows (","). I assume my array is null.

Can someone help me?

1

There are 1 best solutions below

0
On
public var dragArray:Array = [obj1, obj2;

There's a typo in there. You forgot the closing bracket. (]).

public var dragArray:Array = [obj1, obj2];

The closing bracket is part of the instantiation syntax. Add that and you should be good to go.

Although it doesn't appear you are actually instantiating obj1 and obj2, so you are going to run into problems there are your array just has two null objects in there.