# Dynamic Text

**URL:** <https://forum.kirupa.com/t/dynamic-text/22944>\
**Category:** Uncategorized\
**Created:** [June 10, 2003, 10:14pm UTC](https://forum.kirupa.com/t/dynamic-text/22944 "2003-06-10T22:14:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ropeofsilicon](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ropeofsilicon](https://forum.kirupa.com/u/ropeofsilicon)\
**Post date:** [June 10, 2003, 10:14pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/1 "2003-06-10T22:14:26Z")

</div>

I have created a news ticker and I would like to load dynamic text into it. The ticker flows from right to left and works on a continuous loop. How do I load the dynamic text?

---

<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:** [June 10, 2003, 11:48pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/2 "2003-06-10T23:48:22Z")

</div>

you can use the following code to load from text file

[AS]

loadText = new loadVars();  
loadText.load(“filename.txt”);  
loadText.onLoad = function() {

```
           statement.text = this.message;

```

};

[/AS]

the file should be in the same folder as the swf file or you must use relative addressing to load it.

you text file must begin with:  
message = blablabla…

statement is the instance name of your text field

or if you want to load text directly from flash you can simply put  
statement.text = “the text you want here”

---

<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:** [June 19, 2003, 8:26pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/3 "2003-06-19T20:26:14Z")

</div>

hello, i’m new to flash.  
i need help regarding problems of displaying different text in a single dynamic text box. You see, i am able to make it work using kirupa’s tutorial, but how do i write a actionscript for a button to display another text in the same text box? I been using the command:

scroller.text = this.maintext2;

but it gives me nothing in place of the former text. I’m rather puzzled by this. And also i wrote the maintext.txt with the the following :  
maintext1 = blah blah blah …  
&maintext2 = blah blah blah …

is it gonna work with my problematic method? Your kind advice pls, thanks.

---

<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:** [June 19, 2003, 8:27pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/4 "2003-06-19T20:27:10Z")

</div>

I think you spoke too soon 😉

Kirupa recently added up a tutorial on this exact thing…

[http://www.kirupa.com/developer/mx/multiple\_dynamictext.htm](http://www.kirupa.com/developer/mx/multiple_dynamictext.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:** [June 19, 2003, 8:34pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/5 "2003-06-19T20:34:48Z")

</div>

cool, that was a another superb tutorial 😉

but it seems that there were 1 different text file for each text, is it possible to have them together separated by (&) and displayed properly?

---

<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:** [June 19, 2003, 8:39pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/6 "2003-06-19T20:39:26Z")

</div>

Of course…

[AS]loadText = new loadVars();  
loadText.load(“text1.txt”);  
loadText.onLoad = function(success) {  
if (success) {  
newsBox.html = true;  
newsBox.htmlText = this.myNews1;  
}  
};[/AS]

Put that on a frame

This in the textfile…

> myNews1=This is Text one  
> &myNews2=This is Text Two  
> &myNews3=This is Text Three

And this on the buttons…

[AS]on (release) {  
newsBox.htmlText = loadtext.myNews1;  
}[/AS]  
(of course you change myNews1 to the correct variable name)

---

<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:** [June 19, 2003, 8:43pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/7 "2003-06-19T20:43:58Z")

</div>

it works, thanks almighty !

So glad now its possible, or else i’m forever stuck here! 🙂

---

<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:** [June 19, 2003, 8:44pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/8 "2003-06-19T20:44:21Z")

</div>

Also you can clear out the textbox (so the scrollbar resets back at the top) by adding that into an on(press)…  
[AS]on (press) {  
newsBox.htmlText = “”;  
}  
on (release) {  
newsBox.htmlText = loadtext.myNews1;  
}[/AS]

Im sure theres an easier (more efficient) way to do this, but right now Im in a rush and I can’t think of one.

Gotta go. Later.

---

<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:** [June 19, 2003, 9:18pm UTC](https://forum.kirupa.com/t/dynamic-text/22944/9 "2003-06-19T21:18:38Z")

</div>

Lostinbeta, yea i think u can achieve the same effect with this code:

[AS]  
on (release) {  
newsBox.scroll = 0; //resets scrollbar position to 0  
newsBox.htmlText = loadtext.myNews1;  
}  
[/AS]
