Archive
This is an archived tutorial about Flash. It's kept for history and may reference outdated tech.
TL;DR
You load text from external files into a multiline dynamic text box by giving each button an on (release) handler that creates a LoadVars object, loads a file like TEXT1.txt, and in onLoad sets newsBox.htmlText = this.myNews. Each text file starts with myNews= before its text.
- Set the text box's instance name and make it multiline in the Properties panel before writing any code.
- Draw three boxes, convert each to a Button with F8, and give every button the same code with only the file name changed.
- Save the files as TEXT1, TEXT2, and TEXT3 so the names match the ones in your button actions.
- Inside onLoad, the code checks success and sets newsBox.html = true before assigning the loaded text.
This is an archived tutorial from the kirupa.com legacy collection. It covers software that may no longer be available, but it is kept online because the ideas still hold up.
You will be creating something similar to the following animation. Be sure to click on the number buttons to see what happens:
Before we begin, you need to set the properties of the text box. Create a new animation, create a textbox, and click on the text box to display the property panel.
Once the panel has been displayed, use the following settings:
[ the important things are the "instance" and the "multiline"]
Making the Buttons
With the dynamic text field created and customized, we need
to create some buttons to make use of the text field.
Therefore, to the right of your text field draw three boxes.
Your workspace should look similar to the following image:

[ you can make the buttons as fancy as mine if you want ]
Once the boxes have been drawn, select each box and press
F8. From the dialog box that appears, select the option for
Button and press OK. Repeat the previous step for the
remaining two boxes.
Now, right click on a button and select Actions. Copy and
paste the following code:
[ copy and paste the above code ]
Code Explanation:
This is the name of the .txt file you want
to load (the only part you change is the word TEXT1 to the
name of your .txt file)
This is the variable you add to the start
of your text files. I'll explain more in a few moments. If
you remember, we added the actions to only one button. Copy
and paste the exact set of code you pasted for your first
button to the other buttons. Just remember to change TEXT1.txt
to TEXT2.txt and TEXT3.txt in each of the other buttons.
Creating the .TXT Files
Open a ASCII text editor like Notepad (or Notepad if you have it
External resource (archived resource unavailable)
) and type some text.
Now go back to the first line (before all of your text) and
add "myNews=" without including the quotation works. See the
following image for further clarification:
[ format the text in your Notepad/ASCII editor in a similar fashion ]
Make sure that you save the text file as TEXT1, TEXT2, and TEXT3. The file name has to correspond with the names you provided in your Actions a few moments earlier.
If you have any questions, don't hesitate to post on the forums.
chris99022
Before you go, here are a few things you can do:
-
Keep reading
Read the next article in the series, Looking at the New Publish Settings Dialog, or check out some related content:
-
Ask a question
Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.
Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy kirupa's books, became a paid subscriber, watch the videos, and/or interact on the forums.
Your support keeps this site going! 😇
