0
votes

My code is not working, and I am not sure why.

package  {

import flash.display.MovieClip;
import flash.events.Event;


public class enemys extends MovieClip {

    public var playz:Circles 

    public function enemys() {

        stage.addEventListener(Event.ENTER_FRAME, hittrue)
        stage.addEventListener(Event.ENTER_FRAME, moving)

    }

    public function hittrue(event:Event) {


        if (this.hitTestObject(playz)) {

            while (numChildren > 0) {

                removeChildAt(0)
            }

            gotoAndStop(2)
        }

    }

}

It has to do with the variable playz: it says it is null yet I defined it in the variable section.

1

1 Answers

0
votes

You have created a variable which's referencing a Circles object, but you did not give it a refernece aka did not instantiate a new Circles instance and put it in the playz variable.
You should create a new instance and store it in the playz variable before you start using it, else you get that error.

playz = new Circles();