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

  • SEARCH
  • Home
  • 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 8378229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:52:58+00:00 2026-06-09T15:52:58+00:00

So, I have this Player.as class file with the following code: private function PressAKey(event:KeyboardEvent):void

  • 0

So, I have this Player.as class file with the following code:

private function PressAKey(event:KeyboardEvent):void
 {
   getDistance();
   if(event.keyCode == 32 && placedBomb == false && bombNumber == 0)//space
 {
   xKey = true;
   placeBomb();
   placedBomb = true;
}
}

Using this in conjunction with the following placeBomb() function:

private function placeBomb():void{

 MainClass.container.addChildAt(bomb,0);
 bomb.x = this.x;
 bomb.y = this.y+20;
 bombNumber ++;
}

The problem comes from this function which is trying to calculate the distance between the player and the bomb so that I can start building interactions:

private function getDistance():void{
 distance = Math.sqrt( ( this.x - MainClass.container.bomb.x ) * ( this.x - MainClass.container.bomb.x ) + ( this.y - MainClass.container.bomb.y ) * ( this.y - MainClass.container.bomb.y ) );
 trace(distance);
}

I get this error when I try this:

TypeError: Error #1010: A term is undefined and has no properties.
at Player/getDistance()
at Player/PressAKey()

Do you have any idea what I’m missing? It’s definitely a scoping issue, so what would I need to include in order for the entire class to recognize the bomb?

  • 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-09T15:53:00+00:00Added an answer on June 9, 2026 at 3:53 pm

    bomb is no property of MainClass.container. bomb is a only child.

    refer a following code.

    private function getDistance():void
    {
       var bomb:DisplayObject = MainClass.container.getChildAt(0);
    
       distance = Math.sqrt( ( this.x - bomb.x ) * ( this.x - bomb.x ) + ( this.y - bomb.y ) * ( this.y - bomb.y ) );
       trace(distance);
    }
    

    How to reference all the children.

    for(var i:int = 0; i<parentObject.numChildren; i++)
    { 
       var object:DisplayObject = parentObject.getChildAt(i);
       /*
       p.s: if a child object type is MovieClip. must be typecasting.
       var object:MovieClip = parentObject.getChildAt(i) as MovieClip;
       */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following 3 classes in my dbml file: public class Player {
This is my problem: I have a player class and SwipeDetector Class in c#,
I have the following code which searches a text file on my phone's sd
EDIT: Switched from XmlTextWriter to XElement I have a Player class, which has following
I have an xml file with the following information. <?xml version=1.0?> -<Party> -<Player> <Name>Butch</Name>
This is how I currently compile my code: jar cvf client.jar tileGen.class tileGen$GamePanel.class Player.class
I have this game where balloons are coming from bottom and player has to
I'm using a Class Library exporting a function via COM. When calling this function
I am using the following code to display a video file in the android
I have this code: level = {0, 0, 0, 0, 1, 0, 0, 0,

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.