# Loading external text files (flash 8)

**URL:** <https://forum.kirupa.com/t/loading-external-text-files-flash-8/188679>\
**Category:** flash\
**Created:** [May 10, 2006, 12:01am UTC](https://forum.kirupa.com/t/loading-external-text-files-flash-8/188679 "2006-05-10T00:01:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pak](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@pak](https://forum.kirupa.com/u/pak)\
**Post date:** [May 10, 2006, 12:01am UTC](https://forum.kirupa.com/t/loading-external-text-files-flash-8/188679/1 "2006-05-10T00:01:15Z")

</div>

I found a tutorial that explained how to load an external text file into a text field and that worked fine. The issue I’m having is when I try to load the text file into a variable that isn’t a text field object.

The code from the tutorial was:

```auto

textLoader = new LoadVars();
textLoader.onLoad = function()
{
    textFieldInstance.text=this.content;
};
textLoader.load("text.txt");

```

The problem I’m having is if after the .load line I have “trace(textFieldInstance.text)”, the output is blank (presumably its initial value). I’ve tried using some other variable in place of “textFieldInstance.text” and I have the same problem. If I do the trace inside the onLoad function, it displays the correct value, but if it’s outside the function it just returns the variable’s initial value. I’m assuming it’s a scope problem, but I’m not sure how to resolve it. Any help would be appreciated.

Thanks,  
Deepak
