# I can't get my xml data out of the onload function

**URL:** <https://forum.kirupa.com/t/i-cant-get-my-xml-data-out-of-the-onload-function/321724>\
**Category:** flash\
**Created:** [April 28, 2011, 6:08pm UTC](https://forum.kirupa.com/t/i-cant-get-my-xml-data-out-of-the-onload-function/321724 "2011-04-28T18:08:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonassus](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bonassus](https://forum.kirupa.com/u/bonassus)\
**Post date:** [April 28, 2011, 6:08pm UTC](https://forum.kirupa.com/t/i-cant-get-my-xml-data-out-of-the-onload-function/321724/1 "2011-04-28T18:08:03Z")

</div>

I can’t figure out why this doesn’t work. I need to pass the text in the xml file to an object that needs to be created outside of the onload function so i need access to the data out side of that function. I’ve declared variables to store the data at the class level which i thought would give me access to the data  
please help.

below is the code:

```auto
package {
    
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.*;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.xml.*;
    
    public class Test extends MovieClip {
    private var tlbXML:XML;
    private var tlbNode3:String;

        public function Test() {
        init();
        }    
        
        function init(){
        var tlbLoader:URLLoader = new URLLoader();
        tlbLoader.load(new URLRequest("tlbContent.xml"));
        tlbLoader.addEventListener(Event.COMPLETE, processTlbXML);
        }

        function processTlbXML(e:Event):void {
            var tlbXML = new XML(e.target.data);
            tlbNode3 = tlbXML.tlb.node3.toString();
            //trace works here
            trace(tlbNode3 + " = tlbNode3");
        }
        
        //trace doesn't works here
        trace(tlbNode3 + " = tlbNode3");
        
        }

```
