Load a Text File into Flash
In this tutorial you will learn how to load a txt file into your flash swf. This is a great way to easily change your flash movie text by simply using a text file. All you have to do is set the flash up and change the text file whenever you want to change something.
Step 1 : Add the text box & actionscript
- Let's start off by opening a new flash file and changing the size to 250 px by 250 px for better viewing.
- Add a keyframe (F6) then make sure you have the 2nd frame selected.
- Now select the text tool and create a text box on the stage. This will display the text inside the text file. Make sure the drop down in properties says dynamic text. You also want to make sure the font color is black so you can see the text! Then give the variable name text.

- Click frame 1 and open the actions panel and type stop(); click on frame 2 and type in stop(); again. This tells flash to stop else the movie will keep looping.
Step 2 : Create notepad
- Open up notepad and start off by typing text= Remember text is the variable we are using. If you don't know what a variable is... it basically holds data. So everything after the text= will display in the text box you made on flash in frame 2. So for now just type in anything after the text= such as "This is a test to see if it works".
- Then save the file as text.txt Or you can just click here to download the text file.
Step 3 : Create button & actionscript
- Now we are ready to load the variable. Go to frame 1 and on the 2nd line in the actions panel (under the stop();) type in loadVariablesNum("text.txt", 0); This is telling flash to load the variable text and then open file "text.txt".
- The final step is creating a button (this is optional but it gives you a little more knowledge.) If you did not want a button to display the text then ignore this step and delete the stop(); in the 1st frame.
- Create a new symbol and make sure button is selected, give it any name such as text.

note: If you do not know how to create a button and understand the 4 states then click here to view our button tutorial. I am going to think you already know how to create a button. I am going to create my button and give it a name as "Click me".
- Now drag the button you made onto the main stage, frame 1. Your frames should look like this...
 |  |
| Frame 1 - Has button | Frame 2 - Has text box |
-
Now click on the button in frame 1 and open the actions panel. Type the following actionscript in.
| on(release) {gotoAndPlay(2);} |
on(release) triggers the event to happen which is when the mouse button is released. gotoAndPlay(2) is just telling flash to go to the 2nd frame which has the text file
That's it test the movie and it should look like this example