# Another dynamic text problem

**URL:** <https://forum.kirupa.com/t/another-dynamic-text-problem/65278>\
**Category:** flash\
**Created:** [September 24, 2004, 4:08pm UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278 "2004-09-24T16:08:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JP\_West](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@JP\_West](https://forum.kirupa.com/u/JP_West)\
**Post date:** [September 24, 2004, 4:08pm UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/1 "2004-09-24T16:08:44Z")

</div>

I’ve loaded a text file with my variables in it, and am trying to make buttons change the content of text box to one of my several variables… basicly each button corresponds to a variable that should display a text string.

Can’t get the button to load the variable, when clicked the box displays “undefined”.

Any help would be great.

\*\*All I really need is a code chunk for the variable loading (which I have) and for the individual button (which is where my problem lies)

---

<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 24, 2004, 7:03pm UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/2 "2004-09-24T19:03:56Z")

</div>

post code samples in the future, makes it much easier to assess where your problem is

what code are you using on the button currently?

---

<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 24, 2004, 10:06pm UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/3 "2004-09-24T22:06:40Z")

</div>

Part of the problem is that I have no idea what code to use on the button… I have this in my actions layer:

```auto
 unique = new Date().getTime();
loadMain = new LoadVars();
loadMain.load("data/locations.txt?unique="+unique);
loadMain.onLoad = function(success) {
 if (success) {
  locations.htmlText = this.main;
 } else {
  locations.htmlText = "Error loading data";
 }
}; 

```

and then the code on one of my buttons in my other layer is:

```auto
 on (release) {
 locations.htmlText = this.location1;
} 

```

and it doesnt work, I also tried putting the whole load variables thing onto the button as a test, but that didnt work either.

---

<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 26, 2004, 12:13pm UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/4 "2004-09-26T12:13:24Z")

</div>

**Shameless bump**

Sorry, I really need help with this.

---

<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 27, 2004, 5:10am UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/5 "2004-09-27T05:10:07Z")

</div>

You are passing parameters to a text file? what is the use of that part?

---

<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 27, 2004, 10:44am UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/6 "2004-09-27T10:44:14Z")

</div>

No, I’m loading a text file and displaying text strings within it. I want my buttons to change which string is displayed.

---

<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 27, 2004, 3:38pm UTC](https://forum.kirupa.com/t/another-dynamic-text-problem/65278/7 "2004-09-27T15:38:00Z")

</div>

really not sure what to tell you on that one … i’m confused as to what this.main refers to. is that the name of a variable or what?

i’ve had problems in the past setting this.htmlText you may try using this.text first just to get it to load then worry about formatting it.

without seeing the rest of the file and only looking at this script i’d say the problem is that you’ve loaded vars into a variable called loadMain then you said the text should = main … two different variable names, unless you have that specified as a variable somewhere in the text file you’ve loaded
