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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:12:40+00:00 2026-05-13T11:12:40+00:00

This seems like it should be an easy one but I can’t figure it

  • 0

This seems like it should be an easy one but I can’t figure it out.

I’m trying out a very simple class that, when created, loads and XML file into the class’s property. I must be getting a basic concept tangled up here because I can see the XML coming in just fine in the handleComplete function, but the class property _result remains empty.

What concept am I missing here?

Thanks in advance.

public class MyClass
{
    private var _result;

    public function MyClass()
    {
        var url:String = 'myFile.xml';
        var loader:URLLoader = new URLLoader();
        loader.addEventListener( Event.COMPLETE, handleComplete );
        loader.load( new URLRequest( url ) );

        trace(_result); //returns nothing... didn't I just load it?
    }

    private function handleComplete( event:Event ) : void
    {
        try
        {
            var res:XML = new XML( event.target.data );
            _result = res;

            trace(_result); // this writes the myFile.xml to command line as I would expect.
        }
        catch ( e:TypeError )
        {
            // some error handling code
        }
    }
}

}

  • 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-13T11:12:41+00:00Added an answer on May 13, 2026 at 11:12 am

    The reason that the first trace prints nothing is because the request for the file is not synchronous. This means that it runs in the background and only when it is done (which could take a while if the file is very large or the network connection shaky) does it call the handleComplete function.

    At the time your first trace() is called, handleComplete has not been called yet because the file has not finished loading yet.

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

Sidebar

Related Questions

This seems like it should be fairly simple, but for some reason I can't
This seems like it should be easy, but I can't get the right syntax.
First check out this code. I seems like it should work for me, but
This seems like a simple question, but I can't find it with the Stack
This seems like it should be easy but i've spent way too much time
this is might be a very basic question, but seems like it's not easy
It seems like this should be straightforward but I'm boggling. I've got my listview
This seems like a very simple and a very common problem. The simplest example
This seems like such a trivial problem, but I can't seem to pin how
It seems like there should be something shorter than this: private string LoadFromFile(string path)

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.