# FMX:Loading External variable from text into variable

**URL:** <https://forum.kirupa.com/t/fmx-loading-external-variable-from-text-into-variable/30419>\
**Category:** flash\
**Created:** [September 8, 2003, 6:13pm UTC](https://forum.kirupa.com/t/fmx-loading-external-variable-from-text-into-variable/30419 "2003-09-08T18:13:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![borispc](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@borispc](https://forum.kirupa.com/u/borispc)\
**Post date:** [September 8, 2003, 6:13pm UTC](https://forum.kirupa.com/t/fmx-loading-external-variable-from-text-into-variable/30419/1 "2003-09-08T18:13:24Z")

</div>

Hi!  
Here’s the deal: I want to load an external variable called name from a text file into a local variable in flash called my\_str…here’s what I have:

var loadText = new loadVars();  
loadText.onLoad = function(success) {  
if (success) {  
myVar = this.name;  
\_root.my\_str = myVar;  
//if I trace(\_root.my\_str) here I get the external text fine  
} else {  
trace(“Error loading data”);  
}  
}  
loadText.load(“data.txt”);  
//tracing (\_root.my\_str) here returns undefined

I need to have the variable my\_str available outside the function…any ideas why it isn’t working???  
thanx.
