Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:52:53+00:00 2026-06-02T04:52:53+00:00

I am creating my first flash game with Actionscript3 and Adobe Flash CS5.5. The

  • 0

I am creating my first flash game with Actionscript3 and Adobe Flash CS5.5. The concept of the game is just going to be you’re in a spaceship, and you try to avoid asteroids. The longer you avoid the asteroids the more points you get. I know it is not very original. Suddenly today I got this error:

TypeError: Error #2007: Parameter hitTestObject must be non-null.

What this error is doing is that when the space ship hits the asteroids nothing happens. The spaceship just flies right through.

I have no idea how to fix this. Here is my code:

public class AvoiderGame extends MovieClip
{   
    public var army:Array;
    public var gameTimer:Timer;
    public var avatar:Avatar;

    public function AvoiderGame()
    {
        army=new Array();

        avatar=new Avatar();
        addChild( avatar );
        avatar.x=mouseX;
        avatar.y=mouseY;

        gameTimer= new Timer (25);
        gameTimer.addEventListener(TimerEvent.TIMER, onTick);
        gameTimer.start();

    }
    public function onTick(timerEvent:TimerEvent):void
    {
        if (Math.random() < 0.1)
        {
            var randomX:Number = Math.random() * 400;
            var newEnemy=new Enemy(randomX,-15);
            army.push( newEnemy );
            addChild( newEnemy );
        }

            avatar.x=mouseX;
            avatar.y=mouseY;
            for each ( var enemy:Enemy in army ) 

            enemy.moveDownABit();
        {
            if (avatar.hitTestObject( enemy ))
            {
                gameTimer.stop();
                dispatchEvent( new AvatarEvent( AvatarEvent.DEAD ) );
            }
        }
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:52:55+00:00Added an answer on June 2, 2026 at 4:52 am

    Looks like your brackets are messed up. The for each is only doing the enemy.moveDownABit() line. Move your bracket above that to right after the for loop starts.

    With the bracket where it is right now, enemy is going out of scope, which is why it is Null which is what the error is telling you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just finished creating my first major application in C#/Silverlight. In the end the
I'm creating my first game, and I've currently set up a 'GameState' class, to
How can I modify 2d racing game to seem like isometry? Flash + ActionScript3
Im creating flash game that have the functionality to capture/record its gameplay that can
I'm a php newbie, and I'm creating a Facebook application for my flash game.
I'm creating my first gradle plugin. I'm trying to copy a file from the
I am creating my first wordpress plugin. one of the questions i have is
I am creating my first WPF metro app. I am trying to extend the
I'm creating my first application and I have a window consisting of multiple subclasses
I am creating my first (!) database, and I have run into an issue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.