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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:09:14+00:00 2026-05-18T21:09:14+00:00

I know there a bajillion threads on this topic, and maybe I am retarded,

  • 0

I know there a bajillion threads on this topic, and maybe I am retarded, but this simply isn’t working and I think I am missing something really key?

Lets say I have sprites _testTarget and _testParent nested like this.

_testParent = new Sprite();
this.addChild(_testParent);

_testTarget = new Sprite()
_testParent.addChild(_testParent);

And lets say I want to get the global cords of _testTarget. When I do localToGlobal I always get back 0,0 when I know for a fact its actual cords are like 200,100

var point:Point = new Point(_testTarget.x, _testTarget.y);
    point = _testTarget.localToGlobal(point);  // returns 0,0

var point:Point = new Point(_testTarget.x, _testTarget.y);
    point = _testTarget.parent.localToGlobal(point);  // returns 0,0

var point:Point = new Point(this.x, this.y);
    point = this.localToGlobal(point);  // returns 0,0

var point:Point = new Point(this.x, this.y);
    point = this.parent.localToGlobal(point);  // Breaks, "parent" is null

If it helps, this class/sprite instantiated inside of a sprite, inside of a sprite, inside of a sprite…etc and the reason its cords are 200,100 are because one of its parent containers is set to that – but I thought localToGlobal was supposed to go all the way to very top layer? Help?

  • 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-18T21:09:15+00:00Added an answer on May 18, 2026 at 9:09 pm

    So, props to all you guys suggesting that I look through the rest of my code because it turns out that yes, I am retarded haha. On a hunch (from your advise) I found that the problem had nothing to do with localToGlobal – the problem was that I forgot to wait for the stage to be ready. The solution was very simple:

    public function ClassConstructorOrWhatever(){
        addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
    
        _testParent = new Sprite();
        this.addChild(_testParent);
    
        _testTarget = new Sprite()
        _testParent.addChild(_testTarget);
    }
    
    private function handleAddedToStage(e:Event):void {
        var point:Point = new Point(_testTarget .x, _testTarget .y);
            point = _testTarget.localToGlobal(point); // RETURNS 200,100!!!! :)
    }
    

    So yeah, that was the problem – thanks again guys!

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

Sidebar

Related Questions

I know there is a lot on this topic but I can't get any
I know there have been similar questions on this topic but I wasn't completely
I know there are many threads that talk about this problem but I don't
I know there are a lot of similar questions on SF, but I think
I know there are a lot of questions around on this subject, but I've
I know there are lots of posts similar to this, but after crawling SO,
I know there should be an easy way to do this but I guess
I know there are several questions named like this, but they don't seem to
I know there are plenty of questions like this but I'm sure my case
I know there are similar questions to this, but I haven't quite been able

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.