# External text file used as runthrough - pls help!

**URL:** <https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316>\
**Category:** Uncategorized\
**Created:** [July 12, 2004, 10:17am UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316 "2004-07-12T10:17:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dredd](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dredd](https://forum.kirupa.com/u/dredd)\
**Post date:** [July 12, 2004, 10:17am UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/1 "2004-07-12T10:17:05Z")

</div>

hello,  
i would like to do the following:

have a simple movie with about 200 names popping up and fading out in something like 30 seconds.

my question is the following:

do i have to create an instance for each name - or can i simply create one instance in one frame and have actionscript use the names from an external txt file?

if yes, could anyone help me with the coding - and if it isnt possible - are there alternatives?

thanks and regards, nj

---

<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 13, 2004, 10:31am UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/2 "2004-07-13T10:31:45Z")

</div>

pls help me!

_bump_

---

<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 13, 2004, 10:45am UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/3 "2004-07-13T10:45:41Z")

</div>

hmm…

try using an array with a random # generator

I’m not sure how arrays are scripted, but if you assign all of the names to numbers in an array, then create a random number on a certain event, you assign the numbers to the names in the array, then display them in 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:** [July 13, 2004, 11:05am UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/4 "2004-07-13T11:05:52Z")

</div>

if i were you i would crete a global variable that stores which index name to load. to create a global variable you have to do the following code in one of the frames:

[font=Courier New][color=navy]\_global[/color].vNameIndex=0;[/font]

now open the external file were you are storing then names and edit this file as follows:

[font=Courier New]&Name1=John&[/font]  
[font=Courier New]&Name2=Mary&[/font]  
[font=Courier New]&Name3=Amanda&[/font]

continue…

Now in the first frame of your movie put the code to load the name in the text file. This can be done as follows:

[font=Courier New][color=navy]function[/color] loadFile(fileName){[/font]  
[font=Courier New][/font]  
[font=Courier New]file = new [color=navy]loadVars/color;[/font]  
[font=Courier New][/font]  
[font=Courier New]file.[color=navy]onLoad[/color] = [color=navy]function/color{[/font]  
[font=Courier New][/font]  
[font=Courier New][color=slategray]// Assuming that you put the name i[/color][/font]  
[font=Courier New][color=slategray]// n a text field called txtName. Also note[/color][/font]  
[font=Courier New][color=slategray]// that vNameIndex is the global variable.[/color][/font]  
[font=Courier New]txtName.[color=navy]text[/color]=[color=navy]this[/color][[color=blue]“Name”[/color]+vNameIndex];[/font]  
[font=Courier New][/font]  
[font=Courier New]}[/font]  
[font=Courier New]file.[color=navy]load/color;[/font]  
[font=Courier New][/font]  
[font=Courier New]}[/font]  
[font=Courier New][color=slategray]// Assuming that the file were you [/color][/font]  
[font=Courier New][color=slategray]// store the names is called Names.txt[/color][/font]  
[font=Courier New]loadText([color=blue]“Names.txt”[/color]);[/font]

Now i am assuming that you let the movie move from the first frame to the last one to start over from the first movie. Thus in the last frame you just increase the vNameIndex + 1 and stop if the last name has be loaded. Thus put the following coding in the last frame:

[font=Courier New][color=slategray]// Increasing global variable vNameIndex[/color][/font]  
[font=Courier New][color=slategray]// and assuming you have 100 names in the file[/color][/font]  
[font=Courier New][color=navy]if[/color](vNameIndex \< [color=navy]int/color){[/font]  
[font=Courier New]vNameIndex++;[/font]  
[font=Courier New]}[/font]  
[font=Courier New][color=navy]else[/color]{[/font]  
[font=Courier New][color=navy]stop/color;[/font]  
[font=Courier New]}[/font]

This method workled fine for me!

I Hope it helped  
Simon J.

---

<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 13, 2004, 11:52am UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/5 "2004-07-13T11:52:08Z")

</div>

wow thanks! gonna try that ASAP!

great stuff thanks for the code 😃

---

<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 13, 2004, 12:05pm UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/6 "2004-07-13T12:05:58Z")

</div>

my text file is names Names.rtf and i only have 3 names so far … however it doesnt see mto work. i use your code, is that correct or do i need to change anything else?

thanks in advance!

so i have this in the first frame:

\_global .vNameIndex=0;

function loadFile(fileName){

file = new loadVars ();

file. onLoad =function (){

// Assuming that you put the name i  
// n a text field called txtName. Also note  
// that vNameIndex is the global variable.  
txtName. text =this [“Name” +vNameIndex];

}  
file. load (fileName);

}  
// Assuming that the file were you  
// store the names is called Names.txt  
loadText( “Names.rtf” );

and this in the last frame:

// Increasing global variable vNameIndex  
// and assuming you have 100 names in the file  
if (vNameIndex \< int (3)){  
vNameIndex++;  
}  
else {  
stop ();  
}

---

<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 13, 2004, 3:42pm UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/7 "2004-07-13T15:42:05Z")

</div>

I noticed you are doing a space before the dots

[color=navy]\_global[/color].vNAmeIndex and not [color=navy]\_global[/color] .vNameIndex

I don’t know whether you noticed!  
also you can do the root command before setting the text in the textbox

[color=red]\_root[/color].txtName.[color=navy]text[/color]=[color=navy]this[/color] [[color=blue]“Name”[/color] +vNameIndex];

Also make sure that the textbox you are using is Dynamic and not Static  
try these change and tell me if it works!

---

<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 13, 2004, 3:53pm UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/8 "2004-07-13T15:53:09Z")

</div>

I made a quick example in flash, you can download it from

[http://ict.mcast.edu.mt/ictweb/simoaqui/Names.zip](http://ict.mcast.edu.mt/ictweb/simoaqui/Names.zip)

try it out, the only code there is is in frame 1 and the last frame. This should be the answer for your problem 🙂

Simboy

---

<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 14, 2004, 2:17pm UTC](https://forum.kirupa.com/t/external-text-file-used-as-runthrough-pls-help/57316/9 "2004-07-14T14:17:30Z")

</div>

thanks for posting that file  
works great!
