Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
The text field class is the foundation class for other Flash text-based components such as the text area component and the text input component so let's start our text script work here. All of these classes and components are provided in both the Adobe Flex Framework and in the Flash Authoring Environment. The text field content can be pre-specified in the swf file, loaded from a text file or database or entered by a user interacting with your application. Within a text field, the text can appear as rendered HTML content with images embedded in the rendered HTML. Here is a simple example of a text field here called My Text. I'm going to use the text field class here to type some or have ActionScript type in some words here. If I do a Control Test Movie, you can see there is the text that's been entered by my script here. Here's an example of some rendered HTML content plus an image that I'm pulling in with HTML. Notice that the text field here is named, let's go ahead and click on that and open up the Properties Inspector. There's my Text Box, capital T, capital B and if I do a Control Test Movie, we can see this HTML content rendered on my stage here. Here's the text and some formatting. There's some bold formatting, underlining as well as an image being brought in from the images subfolder in the Work Files folder. Now, after you create an instance of a text field, you can use the Flash.text classes like text format and style sheet to control the appearance of the text. You can see here in this example I'm formatting the width, height, multiline, word wrap, background and border of this rendered text here. You can format text by defining the formatting with a text format object and then assigning that object to the text field. If your text field contains HTML text like my previous example, you can apply a style sheet object to the text field to assign styles to the specific pieces of the text field content. Notice again back in this example, if you open up the Actions Window, you can see that I'm adding the HTML content directly to my script right here. Both the text format object and the style sheet object will contain properties defining the appearance of the text including color, size and weight and the rest of those that I showed you previously. The text format object assigns the properties to all the content within a text field or to a range of text. The style sheet object can give you very precise formatting for specific letters, words, paragraphs or sections of text as well. For example within the same text field, one sentence can be bold red and the next sentence can be blue italic. As you probably already know, there are three types of text in Flash. The type of text within a text field is characterized by its source from one of these three sources. You have dynamic text. This includes text content that's loaded from an external source such as a text file, an XML file or even remote web services can generate dynamic text but it can also be generated by ActionScript. In this file here, Dynamic underscore Text.fla that I've saved into the fla files folder, you actually have three types of text. I have some text that's going to be generated dynamically using ActionScript here in the Celsius text field right here. Input text is any text entered by a user or dynamic text that a user can edit. So here in the Fahrenheit box, let's go ahead and do a Control Test Movie. You can see that I can have users type in various Fahrenheit degree values there in the Fahrenheit text field. I've also go static text. That's this text up here; enter temperature in Fahrenheit and then press enter. Static text is created through the authoring tool only; in this case the Flash text tool in the tools panel. Now with input text, this is text that's again entered by a user. You can set up a style sheet to format input text or use the Flash.text.text format class to assign properties to the text field for this input content. Let's go ahead and press the enter key here and you can see that I'll be generating the dynamic text here in the Celsius text field right there. Let's go ahead and enter in 16 degrees. That's going to give me negative 8.8. Thirty-four degrees is going to be 1.1 and so on. So in this file here you have a demonstration of all three types of text types in Flash. Now, although flash provides several options for displaying text, including text-related components or text tools, the primary way to display text programmatically is through a text field. So let me now move on to the next movie and demonstrate how to modify your text field contents using ActionScript.
| Course: | Adobe Flash ActionScript 3.0 for Designers |
| Author: | James Gonzalez |
| SKU: | 34060 |
| ISBN: | 1-935320-82-3 |
| Release Date: | 2009-11-09 |
| Duration: | 9.5 hrs / 101 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |