Load An External Text File Into Flash

Load An External Text File Into Flash
In the last few tutorials you placed Keyframes along the Timeline to designate the individual webpages of your Flash website and then added the behaviors to the menu buttons that will carry you from page to page on your site. We are now ready to add the text to the individual webpages. One nice thing about Flash MX 2004 is that you can load (or import) external text/HTML files into a Flash movie. This makes maintaining your site easier. All you need to do is update the external files and your Flash site will reflect the changes.

How do we do this? We will use a dynamic text block to display the external text. For those pages that contain more text than can fit on a page, we will add a scrollbar. The scrollbar component is not included in the original version of Flash MX 2004. You will need to download the updater from the MacromediaR website.

https://www.macromedia.com/support/flash/downloads.html

After you have downloaded the updater, you are ready to work on the Contact Us webpage for your site. By necessity this is a long tutorial, so hang in there.

Step 1. Add Dynamic Text Block. The first thing we need to do for the Contact Us webpage is to add a dynamic text block to the Stage. Click on the Keyframe for the Contact section (frame 10) on the Content layer in the Timeline. This will automatically select all the contents on the Content layer. Using the Selection Tool, click on an empty area of the Stage to deselect all contents.

Now click on the Text Tool icon and then click and drag on the Stage to draw the dynamic text block. If you will need a scrollbar, set the width of the text block to allow a space for the scrollbar at the right side of the text block. Set the following values in the Property Inspector.

Text Type: Dynamic Text
Instance Name: Contact_Text
Font: Arial
Font Size: 14
Text Fill Color: Black (#000000)
Bold Style
Align Left
Line Type: Multiline
<> Render Text as HTML

Step 2. Document Properties. We need to make a small change to the document properties settings. Use the Selection Tool to click on an empty area of the Stage to deselect the text block. This will open the Property Inspector for the Document. Click on the Size/Document Properties button to open the Document Properties dialog box. For the Match section, click on the Contents button and then click OK.

Step 3. LoadVars ActionScript. Now we will add the ActionScript that will import the external text file. Click on the Keyframe for the Contact webpage (frame 10) on the Actions layer in the Timeline. At this point, the only code in the Actions Panel should be the stop(); code. Starting on the next line, you will want to add the code below.

Ext_text = new LoadVars();
Ext_text.onLoad = addText;
Ext_text.load("ContactUs.txt");
function addText() {
Contact_Text.htmlText = this.ContactUs;
}

Step 4. Add a UIScrollBar. If you will need a scrollbar for this text block, it's easy to add one. Go to the Components Panel and expand the UI Components list. Click on the icon for the UIScrollBar and drag it to the right side of the inside of the text block. When you release your mouse button, the scrollbar will automatically resize to fit the text block.

Step 5. Save the changes. You can now save the new additions to your movie. Click File> Save.

Continue





RSS
Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map








Content copyright © 2021 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.