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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:25:41+00:00 2026-05-23T18:25:41+00:00

I’ve read some things about async waits in Actionscript but can’t really do it

  • 0

I’ve read some things about async waits in Actionscript but can’t really do it in practice. Here’s a short, simplified version of my code I have in a class:

private function getXML():void {
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, loadXML);
    xmlLoader.load(new URLRequest("test.xml"));
}

private function loadXML(evt:Event):void {
    var xmlData:XML = new XML(evt.target.data);
    this.parseResults(xmlData);
}

private function parseResults(resultsInput:XML):void {      
    this.text = resultsInput.Node.attributes()[0];
}

It’s a standard get xml, when done fire an event and then post the first attribute to a node in the class variable text.

The function I want to call this with is:

// assume doSomething("circle") was called
private function doSomething(shape:String):String {
    this.getXML();

    if (this.text == shape) {
        // draw circle
        return "Drew circle";
    } else {
        return "Not a circle in the node";
    }
}

The problem is I always get Not a circle in the node because the processing step below getXML() executes faster than the event can load, fire, and then store into class variable to be checked. I’ve read everything from using anonymous functions to wait or using states or add event listeners to functions (is that possible?) but I can’t implement them correctly (or did not understand how to implement correctly) so can someone give me an example of how I would do this with the above code?

Things I’ve tried and haven’t worked:

Declaring a function variable in getXML() so the function won’t be done until the xml is read

var f:Function = function loadXML(evt:Event):void {... etc.
then calling f in getXML

Doesn’t work, I’m not sure how to call function variables in actionscript to makethis work

Declaring a state variable xmlLoaderState

in getXML() 
    if (this.xmlLoaderState == "waiting") {
        this.xmlLoaderState = "busy";
    }
in parseResults at the end
   this.xmlLoaderState = "waiting"
then in doSomething()
    while (this.xmlLoaderState  == "busy") {}

This infinite loops, I’m guessing it’s because there’s only one thread so the loop blocks the xmlLoader as well.

  • 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-23T18:25:43+00:00Added an answer on May 23, 2026 at 6:25 pm

    I “solved” the argument problem by making all the arguments in that function also class variables and then using those class variables to check whether the shape is correct. This is a pretty bad abuse of namespaces but I don’t know how else to do it. Even if I augment the complete event I can’t get the arguments into the default URLLoader class which means I’d have to change the built-in URLLoader class to take in custom arguments and that’s just way too much I feel for what seems like a typical problem.

    Hopefully someone comes along and tells me a better solution, I’ll be watching for it, until now this is a temp fix that gets the code to run.

    • 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
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.