# Problem loading XML, does thing in the wrong order

**URL:** <https://forum.kirupa.com/t/problem-loading-xml-does-thing-in-the-wrong-order/244866>\
**Category:** Uncategorized\
**Created:** [November 22, 2007, 8:04pm UTC](https://forum.kirupa.com/t/problem-loading-xml-does-thing-in-the-wrong-order/244866 "2007-11-22T20:04:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugin](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@hugin](https://forum.kirupa.com/u/hugin)\
**Post date:** [November 22, 2007, 8:04pm UTC](https://forum.kirupa.com/t/problem-loading-xml-does-thing-in-the-wrong-order/244866/1 "2007-11-22T20:04:03Z")

</div>

Hi.  
Im completely new to Flash/AS but I have some experience in other programming languages. Im trying to load some external data into my program via this code (somewhat trimmes, but the essentials are there):

vis.fla:

```auto

import visualization.*;
var settings:Settings;

settings = new Settings();
settings.loadSystemParameters();

trace("vis.fla: " + settings.getUpdateInterval());

```

Settings.as:

```auto

package visualization{

import flash.events.*;
import flash.net.*;
import fl.motion.Color;
import flash.errors.*;
import flash.net.URLLoader;
import flash.net.URLRequest;

public class Settings {

    private var updateInterval:int;
    private var settingsLoaded:Boolean;

    public function Settings() {}
    
    public function loadSystemParameters():void {
        trace("System1 loadSystemParameters() start");
            
        var systemXML:XML;
        var loader:URLLoader = new URLLoader();

        loader.addEventListener(Event.COMPLETE, loadingComlete);

        loader.load(new URLRequest("c:\\settings.xml"));

        function loadingComlete(evt:Event):void {
            trace("System1 loadingComplete() start");
            try {
                systemXML = new XML(loader.data);
            } catch (error:Error) {
                trace("Error in the XML file: " + error.message + "
Cannot read the data. Shutting down.");
                //Code to shut down the visualisation goes here.
                
                return;
            }

            // Load the data.
            this.updateInterval = systemXML.updateInterval.text();
            trace("Settings: " + this.updateInterval);
                
            trace("System1 loadingComplete( end)");
        }
        trace("System1 loadSystemParameters() end");
    }

    
    public function getUpdateInterval():int {
        return this.updateInterval;
    }
        
}//End System

}//End package

```

What happens when i execute is this:

```auto

System1 loadSystemParameters() start
System1 loadSystemParameters() end
vis.fla: 0
System1 loadingComplete() start
Settings: 600
System1 loadingComplete( end)

```

So the code in the vis.fla is executed to the end before all the data from settings.xml is read and I do not want that. I tried searching and reading about this, but i cannot find the solution. Is there some kind of flag you can set so that the system won´t execute the code after the loadSystemParameters() before all of the function is finished?

Thanks
