External text file used as runthrough - pls help!

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

pls help me!



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

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]


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.

wow thanks! gonna try that ASAP!

great stuff thanks for the code :smiley:

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)){
else {
stop ();

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!

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


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


thanks for posting that file
works great!