# Help With Dynamic Text

**URL:** <https://forum.kirupa.com/t/help-with-dynamic-text/27494>\
**Category:** flash\
**Created:** [August 3, 2003, 4:44am UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494 "2003-08-03T04:44:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![moshlp](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@moshlp](https://forum.kirupa.com/u/moshlp)\
**Post date:** [August 3, 2003, 4:44am UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/1 "2003-08-03T04:44:42Z")

</div>

hi, here is my question:  
I have two boxes in my webpage,I want in one to appear the name of the songs and when I press a song ,its lyrics appears in the other one,and when I press another song ,the previous lyrics are erased, any ideas???,PLEASE HELP  
the problem is that the lyrics are movieclips,because they have a text scroller

---

<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:** [August 3, 2003, 6:36am UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/2 "2003-08-03T06:36:12Z")

</div>

I’m confused…you have two text boxes, and I’m assuming that your text is loaded from a txt file…

On the button that changes the name of your song, just loadVars the new text into the lyrics box. Your targeting would have to include that movieClip that holds the text box too like:

```auto

_root.movieClipName.textBoxName.text=this.variableInTxtFile;

```

Should change automatically, if I understand…This thread helped someone with a simular situation:  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=30075&highlight=textbox](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=30075&highlight=textbox)

---

<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:** [August 3, 2003, 2:28pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/3 "2003-08-03T14:28:25Z")

</div>

actually ,I don´t know how to do that,can you explain how to load the txt file and the loadVars, PLEASE…

---

<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:** [August 3, 2003, 2:31pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/4 "2003-08-03T14:31:36Z")

</div>

This tutorial explains all about it: [http://www.kirupa.com/developer/mx/dynamic\_scroller.htm](http://www.kirupa.com/developer/mx/dynamic_scroller.htm)

---

<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:** [August 3, 2003, 2:35pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/5 "2003-08-03T14:35:36Z")

</div>

If you get through that tutorial, and you still have problems targeting those text boxes, take them out of the movieClips and plop them on the main stage. A textbox does not need to be a movieClip to have a scroll bar component added to it. That way, you can target your stuff just like they have in the tutorial Voetsjoeba mentioned. (-:

---

<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:** [August 3, 2003, 2:43pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/6 "2003-08-03T14:43:21Z")

</div>

the thing is that in the tutorial they target only one external txt ,what should I add to my buttons to target the different 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:** [August 3, 2003, 2:51pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/7 "2003-08-03T14:51:21Z")

</div>

> \*Originally posted by moshlp \*  
> \*\*the thing is that in the tutorial they target only one external txt ,what should I add to my buttons to target the different txt? \*\*

I don’t get your question, please restate it. Are you loading the song titles dynamically too ?

---

<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:** [August 3, 2003, 2:55pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/8 "2003-08-03T14:55:22Z")

</div>

no really, i just write them in the box in Flash and that´s it,should I load the titles dynamically also?  
As for the tutorial, they don´t use any button to load different txt, and in my case, i have 5 buttons that should load 5 different txt, what do I have to do with my buttons?what sholud I add to make them call a different 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:** [August 3, 2003, 3:45pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/9 "2003-08-03T15:45:45Z")

</div>

another thing: if I load the song titles dynamically,how do I make them buttons?

---

<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:** [August 3, 2003, 4:39pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/10 "2003-08-03T16:39:42Z")

</div>

No, you shouldn’t load your song titles dynamically. For such small amounts of text, it’s not worth the effort loading them dynamically. Lemme see about the loadVars(); for a moment …

---

<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:** [August 3, 2003, 4:50pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/11 "2003-08-03T16:50:10Z")

</div>

Okay, let’s look at some code:

```auto

loadText = new loadVars();
//defines 'loadText' as a variable to accept info
loadText.load("kirupa.txt");
//defines what info to load into 'loadText'

loadText.onLoad = function() {
//when this script runs, this function defines where to put the info
//it just loaded in
		scroller.text = this.kirupatext;
};

```

As we learned in the tut, ‘scroller’ is the name of the text box and ‘kirupatext’ is the variable that Flash will search for in your text file and print out everything after ‘kirupatext=…’

Since you want multiple things, I would do this in the text file. For example:  
songone=These are the lyrics to my song,%0dIt’s a good song%0dlalala!!  
&songtwo=These are the lyrics to the next song%0ddumdedumdum%0dGuitarsolo!!  
etc.  
The & tells Flash that there’s a new variable. The %0d is a carridge return (do a search on URL encode later :P). Now, I don’t know if your fla is just one frame, or you have multiple frames or what have you, so I can’t really tell you exactly what to do in your case. I would put all the actions in my buttons like:

```auto

on(press){
loadText = new loadVars();
loadText.load("songlyrics.txt");
loadText.onLoad = function() {
		lyricsBox.text = this.songone;
}
}

```

Then on another button…

```auto

on(press){
loadText = new loadVars();
loadText.load("songlyrics.txt");
loadText.onLoad = function() {
		lyricsBox.text = this.songtwo;
}
}

```

Play with that for a while (-:

How to make your text a button, I would just put a button in a layer underneath your textbox. Here’s an example. Goto my site:  
[http://www.freddythunder.com](http://www.freddythunder.com)  
On the top left side, click the bottom bar of the ‘music box’. Four song names will pop up. These song names are loaded dynamically and there are buttons underneath them.

Whew - that was a long post!!

[edit]Voetsjoeba - Loading the names would be benificial if he needs to ever change them -to avoid the cache situtation, correct? – And man, I hope you’re not typing out the same thing I did…if so, I’m sorry!!:P[/edit]

---

<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:** [August 3, 2003, 4:53pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/12 "2003-08-03T16:53:56Z")

</div>

I’m making a FLA, set up the way you posted 😛

---

<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:** [August 3, 2003, 4:57pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/13 "2003-08-03T16:57:32Z")

</div>

> Voetsjoeba - Loading the names would be benificial if he needs to ever change them -to avoid the cache situtation, correct? – And man, I hope you’re not typing out the same thing I did…if so, I’m sorry!!😛

Well, if he ever needs to change them he’ll just have to open up Flah and change a tiny bit of text 😛 About the cache situation - I have a SWF with dynamically loaded text, and the cache problem remains :-\ But, for a friend of mine, the cache problem isn’t there. So that kinda confuses me. But, I suppose the cache problem won’t be there, and probably it’s just my pc being weird 😛

---

<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:** [August 3, 2003, 5:00pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/14 "2003-08-03T17:00:46Z")

</div>

i have a fla of the textboxes,if you can do something with them,i´d appreciate it.These are the same as I have in my page  
in the left one i want to write the name of the songs,and in the other one, the lyrics

---

<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:** [August 3, 2003, 5:12pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/15 "2003-08-03T17:12:33Z")

</div>

Where are the buttons to switch songs ? Have you tried Freddy’s method ?

---

<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:** [August 3, 2003, 5:15pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/16 "2003-08-03T17:15:07Z")

</div>

i haven´t done them yet.  
I´m trying to make the button behind the layer, but i can´t.  
Anyway, i think I´ll just make them in the stage instead of loading them dynamically

---

<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:** [August 3, 2003, 5:18pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/17 "2003-08-03T17:18:00Z")

</div>

Repost when you have the switchbuttons 🙂

---

<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:** [August 3, 2003, 5:34pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/18 "2003-08-03T17:34:55Z")

</div>

Check if this helps

---

<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:** [August 3, 2003, 5:36pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/19 "2003-08-03T17:36:02Z")

</div>

here are the textboxes with the buttons.I added the code you gave me,and changed the names and stuff, but they don´t seem to work,can you tell me what´s wrong?

---

<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:** [August 3, 2003, 5:45pm UTC](https://forum.kirupa.com/t/help-with-dynamic-text/27494/20 "2003-08-03T17:45:27Z")

</div>

Here

[Next page](https://forum.kirupa.com/t/help-with-dynamic-text/27494.md?page=2)
