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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:31:34+00:00 2026-05-30T22:31:34+00:00

I’m trying to get a value from a function which is a URLLoader COMPLETE

  • 0

I’m trying to get a value from a function which is a URLLoader COMPLETE event but even with declaring variables outside of the function will not allow me to get the value out. I’m stuck.

It seems that the Asynchronous nature of Flash makes it impossible to get a value out: e.g. this works:

// Initialise a URLLoader to get XML data from XML file
var myFPBLoader:URLLoader = new URLLoader();
myFPBLoader.load(new URLRequest("flightPlannerBoard.xml"));


// Check XML data fully loaded
myFPBLoader.addEventListener(Event.COMPLETE, processFPBxml);

var myXML:XML = new XML();// Declared **outside** function

function processFPBxml(e:Event):void {
this.myXML = XML(e.target.data);
trace("yep" + myXML); // This works
myTraceXML();
 }

function myTraceXML(){
 trace("more tests:" + myXML); // **This trace works**
}

trace("more tests:" + myXML); // This **doesn't** work

How do you get a value you can use whenever, wherever you want?

  • 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-30T22:31:36+00:00Added an answer on May 30, 2026 at 10:31 pm

    Here’s what is happening in your code:

    1. functions processFPBxml(), myTraceXML() and variables myFBPLoader and myXML are declared.
    2. XML starts loading myFPBLoader.load. The code does not stop at this point. The loading is asynchronous call and the rest of the code is being executed immediately.
    3. an empty XML gets traced trace("more tests:" + myXML); // This **doesn't** work
    4. XML is loaded and Event.COMPLETE is dispatched.
    5. EventHandler assigned to the forementioned Event call the response: processFPBxml(). At this point the myXML is assigned to the downloaded data.
    6. myTraceXML() is called.

    Now if you want to continue code execution after the XML is loaded, you have to divide your code into separate functions that make specific tasks and call those functions after you get the data from XML. In this case, you could rename myTraceXML() to init() or anything that makes sense to you and write the rest of the program (not necessary in this particular function. Use it as the starting point).

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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 used javascript for loading a picture on my website depending on which small

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.