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

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".

Loading Text From a File

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
Final results of our readers
New!
Passed through all the steps? Share your result!
Your result will be premoderated.
Please make sure you choose the right image.
 
 



Captcha

*Required fileds
Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website. More Flash Tutorials: Featured Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Reader's comments
comments john September 24, 2010 says:
great thanks!
Reply
Add comments to "Loading Text From a File"

Captcha