# Setting a loadmovie swf name dynamically from a txt file

**URL:** <https://forum.kirupa.com/t/setting-a-loadmovie-swf-name-dynamically-from-a-txt-file/62919>\
**Category:** flash\
**Created:** [September 1, 2004, 4:57pm UTC](https://forum.kirupa.com/t/setting-a-loadmovie-swf-name-dynamically-from-a-txt-file/62919 "2004-09-01T16:57:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rynokins](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@rynokins](https://forum.kirupa.com/u/rynokins)\
**Post date:** [September 1, 2004, 4:57pm UTC](https://forum.kirupa.com/t/setting-a-loadmovie-swf-name-dynamically-from-a-txt-file/62919/1 "2004-09-01T16:57:33Z")

</div>

As the title of this post says, I’m trying to have the swf name in the loadmovie line to be generated from a txt file…

The text file (named “swfvariable.txt”) goes as such:

```auto
variable=swfpick

```

And the script goes like this:

```auto
loadVarsText = new loadVars();
loadVarsText.load("swfvariable.txt");
name = this.variable;
picked = ("load_"+name+".swf");
loadMovie(picked, "_root.target");

```

When I create a dynamic text field with the var name “name” - the variable “swfpick” shows up in it. But no matter what, so far, all I’m getting is the movie trying to load in “load\_.swf”

Any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2004, 6:21pm UTC](https://forum.kirupa.com/t/setting-a-loadmovie-swf-name-dynamically-from-a-txt-file/62919/2 "2004-09-01T18:21:16Z")

</div>

> [@rynokins](#):
>
> As the title of this post says, I’m trying to have the swf name in the loadmovie line to be generated from a txt file…
> 
> The text file (named “swfvariable.txt”) goes as such:
> 
> ```auto
> variable=swfpick
> 
> ```
> 
> And the script goes like this:
> 
> ```auto
> loadVarsText = new loadVars();
> loadVarsText.load("swfvariable.txt");
> name = this.variable;
> picked = ("load_"+name+".swf");
> loadMovie(picked, "_root.target");
> 
> ```
> 
> When I create a dynamic text field with the var name “name” - the variable “swfpick” shows up in it. But no matter what, so far, all I’m getting is the movie trying to load in “load\_.swf”
> 
> Any ideas?

I`m not sure variable is such a good name for a variable but how you have written this, flash is looking for a vaiable on the timeline. Put it like this to see if its anybetter  
loadVarsText = new loadVars();  
loadVarsText.onLoad=function(){  
name = this.variable;  
picked = (“load\_”+name+“.swf”);  
loadMovie(picked, “\_root.target”);  
}  
loadVarsText.load(“swfvariable.txt”);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2004, 6:25pm UTC](https://forum.kirupa.com/t/setting-a-loadmovie-swf-name-dynamically-from-a-txt-file/62919/3 "2004-09-01T18:25:48Z")

</div>

> [@stringy](#):
>
> I`m not sure variable is such a good name for a variable but how you have written this, flash is looking for a vaiable on the timeline. Put it like this to see if its anybetter  
> loadVarsText = new loadVars();  
> loadVarsText.onLoad=function(){  
> name = this.variable;  
> picked = (“load\_”+name+“.swf”);  
> loadMovie(picked, “\_root.target”);  
> }  
> loadVarsText.load(“swfvariable.txt”);

your textfield will no longer pick up the variable unless you include a path

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2004, 7:23pm UTC](https://forum.kirupa.com/t/setting-a-loadmovie-swf-name-dynamically-from-a-txt-file/62919/4 "2004-09-01T19:23:56Z")

</div>

I used ‘variable’ in my post to make it clear and non-specific. Also, outputting the variable to a text box was just to see if I was getting it from the txt file.

This totally worked. Thanks so much!

:bu:

by the way, in my txt file, i had the variable in quotes, as I had left it from one bout of troubleshooting. The script you gave me returned the variable in quotes, which of course did not work, so I deleted the quotes and then it worked perfect. Thanks again.
