Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Loading Text From a File
Your Ad Here

Loading Text From a File


Requirements

  • Flash MX or higher.

1. Start by creating a new document in Flash.

2. Select the Text Tool, and change the Text Type to Dynamic.

3. Draw a text box on the Stage, this is where the text from the file will be displayed.

4. Select the text box with the Selection Tool, and give the text box an instance name of "tDisplay".

image 1

5. Select Frame 1 of your movie and press F9 to open the Actions Panel.

6. Add the following code to the Actions Panel:

lvLoader = new LoadVars(); //Declares a LoadVars named lvLoader.
lvLoader.onLoad = function(success) //When the file is loaded this function is called.
{
        if(success) //If file is succesfully loaded.
        {
                tDisplay.text = lvLoader.tContent; //Change tDisplay's text to show the tContent that was loaded through lvLoader.
        }
}
lvLoader.load("text.txt"); //Load the text file.

7. Now open up Notepad or another basic text editor. (Not Microsoft Word)

8. Type:

tContent=This is the text that will be loaded.

9. Save the file as "text.txt" (The extension .txt is already added in notepad) in the same folder as your flash document.

10. When you test your Movie it should now load the text from the text file and display it in the text box.

11. If you wish to load more than one variable then separate them with "&" like:

tContent=This is the text that will be loaded.&tContent2=This is more text that will be loaded.


Author's URL: Tutorial Scene
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Loading Text From a File"

Only registered users can write comment

Reader's comments