0
votes

I am trying to test for the collision of two objects. Both are on the display list. They are movie clips, each containing a hit box. One is called hitboxx, and the other is called hits. However, when I test the following code:

if (character2.hitboxx.hitTestObject(Spike1.hits)||character2.hitboxx.hitTestObject(Spike2.hits)||character2.hitboxx.hitTestObject(Spike3.hits))
{
    currLives--;
}

I get this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at SpikeJungle_fla::MainTimeline/frame1()[SpikeJungle_fla.MainTimeline::frame1:126]

1
There are not two but four objects. hitboxx, Spike1, Spike2, Spike3. - Andrei Nikolaenko
In your debugger, you can find which variable is null. - Nambew

1 Answers

0
votes

it's difficult to say anything on the code. The code seems correct. May be you forget to add variable name or something. Or try to check one movie clip at a time. means try to remove the other condition in and check with one and see whether it's working. And also in Publish Settings >> Advanced >> permit Debugging check this option and compile again and you will get more about the errors.