Macromedia Flash 8 Bible Free Open Book

Macromedia Flash 8 Bible

Previous Page
Next Page

Text Scrolling with the TextArea Component

Continuing from the previous Flash movie example with the digital video production presentation, you learn how to create basic scrolling text using the TextArea component in Flash 8. You can scroll text in Flash 8 with either the UIScrollBar or the TextArea component. We will demonstrate the use of the TextArea component for one item in the videoEquip symbol to get you started.

  1. In the Flash document you created from the previous section, double-click the mcEquip instance on the Stage, at frame 10 of the content layer. Flash 8 switches to Edit mode.

  2. Add a new layer, and rename it ctaDesc. (We use the prefix cta to designate a TextArea component, and the Desc is short for description.) Move this layer beneath the buttons layer, and select frame 1 of the ctaDescription layer. Now, open the Components panel (Ctrl+F7 or z+F7). In the UI Components nesting, drag an instance of the TextArea component to the Stage, to the right of the mcTape instance.

  3. Use the Free Transform tool to stretch the component instance. This instance should accommodate several lines of text, as shown in Figure 20-17. The size of the instance should match the size of the text area you wish to display in the scrolling text window. In the Property inspector, name the TextArea instance ctaDesc. In the Parameters tab of the inspector, change the html setting from false to true. The html setting controls whether or not the instance should interpret HTML tags. Also, change the editable setting to false; the user should not be able to change the contents of the text field at run time.

Image from book
Figure 20-17: This text field will display the text associated with the first video item.

Now, you'll need to supply some text to the ctaDesc instance. You can specify text directly in the text parameter of the instance in the Property inspector, but for this project, you'll learn how to format HTML text that is assigned in ActionScript to the TextArea component. Open the item_1.rtf document in a text editor such as WordPad or TextEdit. This file is located in the ch20/text folder of this book's CD-ROM. Now, open the item_1_formatted.txt document on the CD-ROM, and compare it to the item_1.rtf version. (You may want to enable word wrapping in your text editor so that you can see all of the text in the TXT file.) You'll notice that all of the text in the TXT file is specified in one continuous nonbreaking line. Moreover, any carriage returns in the item_1.rtf have been replaced with <br/> tags in the TXT version. Some characters, such as the double quotes around the word "data," have been escaped in the TXT file — that is, the character is preceded by a backslash (\). These special formatting characters ensure that ActionScript will correctly display the text.

  1. Select all of the text in the item_1_formatted.txt file, and copy it. Later in this exercise, you'll paste the text into your own ActionScript code.

  2. On the videoEquip timeline, create a new layer and rename it actions - text. Place this layer at the top of the layer stack. Select frame 1 of the new layer, and open the Actions panel (F9, Option+F9 on Mac). In the Script pane, type the following code:

    ctaDesc.text = "";
    
    
  3. Between the pair of double quotes you typed in Step 5, paste (Ctrl+V or z+V) the copied text into the Script pane. Initially, the text should be displayed on one line, but you can choose Word Wrap in the options menu of the Actions panel to see all of the text, as shown in Figure 20-18.

  4. Save the Flash document as main_500.fla, and test it (Ctrl+Enter or z+Enter). Click the Video Equipment navigation button, and try the TextArea component. If the text is not displaying or scrolling, go back to the authoring environment and double-check the ActionScript code on frame 1 of the actions text layer. Do not proceed with any steps until the TextArea component is functioning properly.

  5. Now, you're ready to set up the text for the second item on the videoEquip timeline. Select frame 2 of the actions text layer, and press F7 to insert an empty keyframe. Add the same actions and text as shown in Steps 5 and 6, but this time, copy and paste the text from the item_2_formatted.txt file (located in the ch20/text folder of this book's CD-ROM).

  6. Save your Flash document again, and test it (Ctrl+Enter or z+Enter). When you navigate to the Video Equipment section, you should be able to click the Next button to see the text for item 2.

  7. Repeat Step 8 for frames 3, 4, 5, and 6 of the actions - text layer. When you are finished, you should have six separate action keyframes, one per item on the timeline.

  8. Save your Flash document again, and test it (Ctrl+Enter or z+Enter). When you go to the Video Equipment section, you should be able to click the Next button to reach each video item's description field, and the field should be scrollable.

Image from book
Figure 20-18: The Actions panel displaying the code to assign text to the TextArea component

The next step in real production would be to finesse the artwork and to add transitional effects between each video item. In the next section, we show you how to add a custom Fade component that we created for your use in this exercise.

Tip 

If you want the scroll bar's position to reset for each new item, add the following ActionScript code after you set the text property on each frame:

ctaDesc.vPosition = 0;

The vPosition property controls the vertical position of the scroller. Setting it to zero resets the position to the top. So, if the user scrolls to the bottom of one description and presses the Next button, the next item's description will read from the top. This extra line of code was added to the main_500.fla file found on the book's CD-ROM.

On the CD-ROM 

You can find the completed document, main_500.fla, in the ch20 folder of this book's CD-ROM.


Previous Page
Next Page
Index: [A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y][Z]


     Main Menu
Table of Contents
Back Cover
Macromedia Flash 8 Bible
Foreword
Preface
Part I: An Introduction to Flash Web Production
Part II: Mastering the Flash Environment
Part III: Creating Animation and Effects
Part IV: Integrating Media Files with Flash
Part V: Adding Basic Interactivity to Flash Movies
Chapter 18: Understanding Actions and Event Handlers
Chapter 19: Building Timelines and Interactions
Chapter 20: Making Your First Flash 8 Project
The Main Timeline as the Site Layout
Adding Navigation Elements to the Main Timeline
Text Scrolling with the TextArea Component
Using the Custom BlurFader Component
Adding Named Anchors
Making the Movie Accessible
Summary
Part VI: Distributing Flash Movies
Part VII: Approaching ActionScript
Part VIII: Applying ActionScript
Part IX: Integrating Components and Data-Binding
Part X: Expanding Flash
Part XI: Appendixes
Index
List of Figures
List of Tables
List of Listings
List of Sidebars


More Books
PHP Hacks
Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
The Koran (Holy Qur'an)
Macromedia Flash 8 Bible
Search Engine Optimization for Dummies
YouTube Traffic
PHP 5 for Dummies
Harry Potter and The Chamber of Secrets
Harry Potter and the Sorcerer's Stone
The Pilgrim's Progress
Wireless Hacks
Flash Hacks. 100 Industrial-Strength Tips & Tools
PayPal Hacks. 100 Industrial-Strength Tips and Tools
Amazon Hacks
Pdf Hacks
The Da Vinci Code
Google Hacks
The Holy Bible
Windows XP For Dummies
Harry Potter and the Half-Blood Prince
Seo Book
Upgrading and Repairing Networks
Macromedia Dreamweaver 8 UNLEASHED
Windows XP Annoyances
Windows XP Hacks
Microsoft Windows XP Power Toolkit
Teach Yourself MS Office In 24Hours
iPod & iTunes Missing Manual
PC Hacks 100 Industrial-Strength Tips and Tools
PC Overclocking, Optimization, and Tuning - 2th Edition
PC Hardware In A Nutshell 3rd Edition
PC Hardware in a Nutshell, 2nd Edition
Upgrading and Repairing PCs
Google for Dummies
MySQL Cookbook
Teach Yourself Macromedia Flash 8 In 24 Hours
PHP CookBook
Sams Teach Yourself JavaScript in 24 Hours
PHP5 Manual
Free Games Paper Airplanes
500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele