# I can´t access downloaded variables outside the function

**URL:** <https://forum.kirupa.com/t/i-can-t-access-downloaded-variables-outside-the-function/89250>\
**Category:** flash\
**Created:** [May 6, 2005, 11:21am UTC](https://forum.kirupa.com/t/i-can-t-access-downloaded-variables-outside-the-function/89250 "2005-05-06T11:21:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ditti](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@ditti](https://forum.kirupa.com/u/ditti)\
**Post date:** [May 6, 2005, 11:21am UTC](https://forum.kirupa.com/t/i-can-t-access-downloaded-variables-outside-the-function/89250/1 "2005-05-06T11:21:57Z")

</div>

I can´t access downloaded variables outside the function.  
I have had this question in forum [Actionscript.org](http://Actionscript.org) but I didn´t got a reply that works for me, so I try this forum.  
I have worked with this for weeks and would really appreciate if I got an answer that will work this out.

```auto
ActionScript:
var loader = new LoadVars();
loader.load("kiruppa.txt");
trace("loader.total1="+loader.total);
loader.onLoad = function(successful){
		if (successful){
				trace("loader.total2="+loader.total);
		}else{
				trace("Error in loading myVariables");
		}
}
trace("loader.total3="+loader.total);
trace("total="+total);

```

the output:

```auto
 loader.total1=
loader.total3=
total=
loader.total2=8

```

trace(“loader.total2=”+loader.total); gave the output loader.total2=8  
That shows that the variable total is loaded successful.  
Then outside the function  
trace(“loader.total3=”+loader.total); gave the output loader.total3=  
trace(“total=”+total); gave the output total=  
the variable was loaded but I can´t access it outside the function. I got the advise to wait until it´s loaded, butI don´t understand how to do.
