# Random Load Text HELP!

**URL:** <https://forum.kirupa.com/t/random-load-text-help/26648>\
**Category:** Uncategorized\
**Created:** [July 25, 2003, 1:02am UTC](https://forum.kirupa.com/t/random-load-text-help/26648 "2003-07-25T01:02:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aussy](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@aussy](https://forum.kirupa.com/u/aussy)\
**Post date:** [July 25, 2003, 1:02am UTC](https://forum.kirupa.com/t/random-load-text-help/26648/1 "2003-07-25T01:02:41Z")

</div>

Hey guys. I’m an amateur flash developer and I need desperate help. I have no skills in random what so ever. I’m trying to make a fortune cookie/advice doodad that randomly loads a line of text from an external txt file but I have no idea how to do it. PLEASE HELP ME!!! I will give you credit in the file and on my site and in resources.

-aussy

---

<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:** [July 25, 2003, 1:31am UTC](https://forum.kirupa.com/t/random-load-text-help/26648/2 "2003-07-25T01:31:09Z")

</div>

Place a textfield on stage. Give it an instance name of “myText” (no quotes).  
Now open your notepad and write the following lines:[AS]text1=text 1 goes here&text2=text 2 goes here&text3=text 3 goes here&[/AS]You can enter as many variables you want. In this example we are working with 3 diferent lines. Save the file as txtfile.txt

Now place the following code on the first frame of your main timeline:[AS]loadText = new loadVars();  
loadText.load(“txtfile.txt”);  
loadText.onLoad = function(OK) {  
if (OK) {  
myText.Text = this[“text”+(Math.floor(Math.random()\*3)+1)]; //i used 3 because we are working with only 3 different texts inside the txt file  
}  
};[/AS]

---

<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:** [July 25, 2003, 1:37am UTC](https://forum.kirupa.com/t/random-load-text-help/26648/3 "2003-07-25T01:37:14Z")

</div>

Thanks A LOT!!! Usually people don’t respond to my plees of help and pity but luckily someone did. Hopefully it works. If so you’ll definitely will be on my thank list.

---

<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:** [July 25, 2003, 1:41am UTC](https://forum.kirupa.com/t/random-load-text-help/26648/4 "2003-07-25T01:41:33Z")

</div>

Im sure it works 🙂  
Good Luck!

😉

[edit] i forgot to say your textfield should be set as dynamic text[/edit]
