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 6895367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:53:58+00:00 2026-05-27T06:53:58+00:00

I’ve been having some strange problems with the collision code of a game I’m

  • 0

I’ve been having some strange problems with the collision code of a game I’m making, and I’ve been able to trace it down to this: the getters of my properties are returning NaN, instead of an actual number.

Here are the declarations of the properties, at the top of the class:

private var _top:Number;
private var _bottom:Number;
private var _left:Number;
private var _right:Number;

And here are the getters:

public function get top():Number 
{
    return _top;
}

public function get bottom():Number 
{
    return _bottom;
}

public function get left():Number 
{
    return _left;
}

public function get right():Number 
{
    return _right;
}

The values become generated by calling the public function setSides(tileSize:Number) of a class instance (the values depending on the tileSize parameter). After I’ve run that, I run a trace which gets the values using the getters, but all of them return NaN.

The thing is, if I run a similar trace within setSides(), without using the getters – i.e. using the variables directly – they return the correct values.
And to make sure, I also did it within the function using the getters, so I’m sure they’re the problem.

Anyone know what’s going on?

EDIT: Here is my setSides() function:

public function setSides(tileSize:Number):void 
{
    var _top:Number = Math.floor(_yPos / tileSize);
    var _bottom:Number = Math.floor((_yPos + 45) / tileSize);
    var _left:Number = Math.floor(_xPos / tileSize);
    var _right:Number = Math.floor((_xPos + 20) / tileSize);

    trace("top: " + top + " bottom: " + top + " left: " + left + " right: " + right); //This gives the correct values, not NaN
}

But even if there was something wrong with my values I’m assigning (which would show in my trace), I’ve assigned a value of 0 to each of the variables in my constructor, so they shouldn’t give NaN from the moment my class is instantiated.

EDIT: Oh man, I just noticed this now. Due to some testing and re-editing I did, I was still using my variables as if I was defining them (with the var and :Number). Also, the “assigning 0 to them” was also before this testing and re-editing I mentioned, so that wasn’t present.

  • 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-05-27T06:53:59+00:00Added an answer on May 27, 2026 at 6:53 am

    Remove the “var” and the type “Number” from your “setSides()” method. Those are local variables. You’re not actually setting anything. Should be:

        _top = Math.floor(_yPos / tileSize);
        _bottom = Math.floor((_yPos + 45) / tileSize);
        _left = Math.floor(_xPos / tileSize);
        _right = Math.floor((_xPos + 20) / tileSize);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
We're building an app, our first using Rails 3, and we're having to build

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.