Callum Singh
Callum Singh

Reputation: 79

AS3 Flash - Error #2007: Parameter hitTestObject must be non-null

I'm using Flash to create a platform game and i'm just trying to add an if statement with hitTestObject in to trace some words but when i hit platforms but I keep getting the error "Parameter hitTestObject must be non-null".

Here's my code:

//variables
public var jon: Player; 
public var platforms:Platform;

public function gameloop(Event)
 {
        //applying gravity
        jon.y += gravity;

        //adding movement
        if (moveLeft == true)
        {
            jon.x -= xspeed;
            jon.scaleX = -1;
        }

        if (moveUp == true && isJumping == false)
        {
                isJumping = true;
                jon.y -= yspeed;
        }

        if (moveRight == true)
        {
            jon.x += xspeed;
            jon.scaleX = +1;
        }


        //adding collisions for platforms   **NOT WORKING**
        if(jon.hitTestObject(platforms))
        {
            trace("hello i am working");
        }
    }

Upvotes: 0

Views: 1141

Answers (1)

Aaron Beall
Aaron Beall

Reputation: 52193

The error indicates that platforms is null.

Neither jon or platforms is created in the code you posted, I'm guessing these are timeline symbols? Make sure you have given a symbol the name platforms in your timeline, and make sure it exists on the frame that gameloop is added.

Upvotes: 1

Related Questions