# XML.Load - sync problem

**URL:** <https://forum.kirupa.com/t/xml-load-sync-problem/133238>\
**Category:** Uncategorized\
**Created:** [January 6, 2005, 9:38pm UTC](https://forum.kirupa.com/t/xml-load-sync-problem/133238 "2005-01-06T21:38:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdance](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@mrdance](https://forum.kirupa.com/u/mrdance)\
**Post date:** [January 6, 2005, 9:38pm UTC](https://forum.kirupa.com/t/xml-load-sync-problem/133238/1 "2005-01-06T21:38:04Z")

</div>

I have understood that XML.Load is asynchros and when using XML.onLoad you really don’t know when the code will be executed. Please look at my script here: [http://neteject.com/examples/flash.txt](http://neteject.com/examples/flash.txt) (I am running the function LoadAll()) and then look at the output here:

Loading  
LoadLangSettings()  
LoadLangFile1()  
LoadLangFile, id: 42,file: undefined  
LoadLangFile2()  
LoadLangFile, id: undefined,file: undefined  
LoadLangFile1() Success:false  
an error occured  
Error opening URL “file:///E|/proj/chatproject/2005%2D01%2D06/client/lang/undefined”  
LoadLangFile2() Success:false  
an error occured  
Error opening URL “file:///E|/proj/chatproject/2005%2D01%2D06/client/lang/undefined”  
LoadLangSettings() Success:true

As you can see, the function in LoadLangSettings executes later which causes some errors because LoadLanguages (which comes after) needs variables which are created in LoadLangSettings. How can I solve this? A sleep function or what?

thanks / Henrik
