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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:35:25+00:00 2026-05-28T23:35:25+00:00

Pretty new flixel/AS3 user here, though not entirely new to coding. Anyways, the error

  • 0

Pretty new flixel/AS3 user here, though not entirely new to coding. Anyways, the error is pretty straightforward in it’s cause, but not it’s solution.

“Error: Access of possibly undefined property through a reference with static type org.flixel:FlxSprite.”

It gets thrown 6 times, twice with the property scrap.selected and four times with scrap.distanceToMouse – I’ve marked each line that throws an error with comments.

I’ve searched throughout the web and StackOverflow specifically. It looks like a pretty common problem, but I haven’t been able to apply any solutions to my specific situation. Anyways, Here’s the relevant code…

ScrapManager.as

    if (FlxG.mouse.pressed)
    {
        var ClosestDistance:int = 500; 
        for each (var scrap:FlxSprite in this)
        {
            scrap.selected = false; //error here!~ 
            var dx:int = scrap.x - FlxG.mouse.screenX;
            var dy:int = scrap.y - FlxG.mouse.screenY;
            scrap.distanceToMouse = (dx * dx) + (dy * dy); //error here!~

            if (scrap.distanceToMouse < ClosestDistance) //error here!~
            {
                ClosestDistance = scrap.distanceToMouse; //error here!~
            }
        }
        for each (var scrap:FlxSprite in this) 
        {
            if (scrap.distanceToMouse == ClosestDistance) //error here!~
            {
                scrap.selected = true; //error here!~
            }
        }
    }

Scrap.as

package 
{
    //import stuff...

    public class Scrap extends FlxExtendedSprite
        {
            public var selected:Boolean = false; 
            public var distanceToMouse:int; 
            //and more stuff...

I think (hope) that’s all that’s needed to solve this, but I’ll be happy to provide more if needed. Thanks for reading. 😀

  • 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-28T23:35:26+00:00Added an answer on May 28, 2026 at 11:35 pm
    for each (var scrap:FlxSprite in this)
    

    Are you certain that every property in “this” is an instance of FlxSprite? Maybe you need to store a collection of the FlxSprites inside ScrapManager and loop through those instead?

    I’d suggest tracing out “scrap” in those loops to make sure it is the right data type. If it is, and it is still giving out those errors, you should be able to narrow it down to the specific object that’s giving you the problem.

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

Sidebar

Related Questions

Pretty new here. But before I ask my question, I'm not looking for teh
Im pretty new to nhibernate so this may be quite straightforward but i havent
Im pretty new to Java Web Services, but I cant find a good explanation
I am pretty new to php, but I am learning! I have a simple
Im pretty new to coding, heres my problem. Results->Text = G55 > Y +
I'm pretty new to CakePHP but I think I'm starting to get the hang
I'm pretty new with Java (though I'm experienced with C#). Anyway I've Googled a
Im pretty new to CI so bear with me here. I have just setup
pretty new to the function, but as i understand DECODE tests the specified attribute
Im pretty new to REST but as far as i have gathered i understand

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.