Static text does not allow for any user input. To change the text, changes must be made in the Flash source file (FLA). Input and dynamic text fields are populated at runtime. To do anything useful with them, you have to access or manipulate the text fields with ActionScript. With input and dynamic text, you create placeholder text fields in the FLA to designate where text will be placed and how it will appear during playback. Input and dynamic text attributes, like static text attributes, are assigned in the Property inspector. Input Text To create an input text field, click the Text tool, select Input Text from the pop-up Text type menu in the Property inspector, and drag out a text field on the Stage where the user can enter text. Or you can convert an existing text block by selecting it and changing the text type to Input Text. The borders of input text fields appear as dotted lines when not selected. Assign text attributes such as font, point size , and font color in the Property inspector as you would with static text. To preview text appearance, type something in the input text field. If you leave text in the field, it will remain there until the user replaces it. For example, you might want the field to initially contain a hint about what the user should enter ("Type your name here"). There are two ways to indicate to users where they should click to enter input text. You can turn on borders around your input text field by clicking the Show border around text button, shown in Figure 17.3. Your input text field appears with a black border and a white background. If this is undesirable, you can position an input field without borders over a shape that can indicate your input boundaries, as shown in Figure 17.4. Alternatively, you can use ActionScript to set the background and border colors. Figure 17.4. Position your input text field over graphic elements to indicate the borders without having a white background appear. Dynamic Text Dynamic text is loaded into your movie at runtime from an external source, such as a text file, a database, or a live feed from a server, rather than assembled in advance in the FLA. This is a good option for content that changes frequently, such as news stories, because content can be updated without edits to the FLA. You create a dynamic text field just like an input text field, except that you select Dynamic Text from the Text type menu. You can type in a dynamic text field to preview text appearance. If you leave text in the field, the user will see that text until other text dynamically replaces it. Because dynamic text boxes use system fonts, you need to chose a system/device font or standard serif or san serif font like Verdana or Times. The alternative is to embed the outlines of a different font. Using a Variable to Set and Get Text One way to control the text in an input or dynamic text field is by associating a variable name with the field. Any value assigned to the variable with ActionScript will appear in the field. Any reference to the variable in your scripts is interpreted by ActionScript as a reference to the text in the field. Use the Var field in the Property inspector to assign the variable. For example, in Figure 17.3, the variable name userName_var was been assigned to the input text field, userName_txt . Text Formatting Options Several text formatting options are specific to input and dynamic text. You must give these text fields instance names to be able to use ActionScript to access their properties. To do so, enter a unique instance name in the Instance Name field, which is beneath the Text type drop-down in the Property inspector. For instance, in Figure 17.3, the instance name was userName_txt . Using the Line type drop-down option, you can specify whether a dynamic or input text field can contain more than a single line of text. The options are Single Line; Multiline, which displays multiple lines of text; and Multiline No Wrap, which displays multiple lines only if the user enters hard breaks with Return (Mac) or Enter (Windows). The Maximum Characters field, as shown in Figure 17.3, allows you to limit the number of characters that can be entered into an input text field. The Render Text as HTML button allows you to use some HTML formatting in the text field. When this option is selected, Flash applies the appropriate formatting to the text at runtime. (This does not work for text you enter in the FLA.) The supported tags include links, bold, break (new line), italic, underline, paragraph, font color, font face, and font size. | In Flash Player 7 and later, you can also include images in the form of JPEGs, SWFs, or movie clips (not GIFs). The ActionScript is simple: | userName_var = "Enter user name: <img src = \"test.jpg\">"; Supported HTML attributes include leftmargin, rightmargin, align indent, and leading. You can also set Render as HTML in ActionScript by using the html property of the TextField object. Finally, this panel contains an option to allow users to select the text. It is turned on by default, as shown in Figure 17.3. If you don't want users to be able to select your text ”to copy and paste it, for example ”deselect the Selectable text button. Embedded and Device Fonts When you create text in Flash, all the fonts installed on your system are at your disposal. However, other users may not have your installed fonts, and different fonts are available on different platforms. Does this mean that your careful formatting of text will go to waste? No, but you need to take steps to ensure that users see the typefaces you want them to see. You have two options. One is to embed font outlines. Embedding allows you to save the outlines of your fonts so that text is displayed in the specified font even if it is not installed on a user's system. Flash anti-aliases embedded fonts unless you select Alias Text. Embedding fonts does add to the overall file size of movies. With static text, you don't need to embed the fonts because the outlines are automatically saved. Fonts used in dynamic and input text fields are by default not embedded and therefore not anti-aliased. To embed fonts, click the Edit character options button just to the right of the Var field. The Character Options dialog box launches. You can choose to embed all the characters in the font. Or you can embed just selected subsets of the font, such as uppercase, lowercase, or numerals. To reduce your file size, embed only the characters you need. For instance, you don't need to embed characters other than numerals for a text field that will contain the year in four-digit format. Not all fonts can be embedded and exported with your movie. Sometimes Flash doesn't recognize font outline information. To test whether a font can be embedded, select the text and click the Alias Text button on and off. If you see no change, Flash does not recognize the font's outlines and cannot embed it. The alternative to embedding fonts is using device fonts. Computer operating systems include a limited number of fonts that are automatically installed. These fonts are different on Macintosh and Windows platforms, but each platform includes a sans serif, a serif, and a typewriter typeface. (See Figure 17.5.) Typewriter typefaces are monospaced , meaning that each letter occupies an identical amount of space. Note that both the capital A and the lowercase i in the typewriter typeface in Figure 17.5 occupy equal amounts of space. Compare this to the serif and sans serif examples. When device fonts are specified, outlines are not embedded, and the Flash Player displays the most similar font that is installed on the user's system. Three device fonts are available: _sans, which typically uses Helvetica (Mac) or Arial (PC); _serif, which typically uses Times or Times New Roman; and _typewriter, which uses fonts similar to Courier. To specify device fonts, select them from the Font pop-up list, as shown in Figure 17.6. Figure 17.6. You can select device fonts from the Font pop-up list in the Property inspector. Device fonts produce smaller file sizes than embedded fonts, but there is an element of uncertainty; if a user doesn't have installed fonts that correspond to specified device fonts, strange and unexpected substitutions may occur. Device fonts are not anti-aliased, so they work best at small sizes where anti-aliasing can make characters appear fuzzy. They may appear noticeably jagged at large sizes because they are not anti-aliased. Breaking Text Apart You can break apart text by using Modify, Break Apart, placing each character into a separate text block. Individual characters in words can then be animated separately. If you break apart the same text a second time, you convert it into graphic shapes . (See Figure 17.7.) Figure 17.7. Break apart text once to place each character into its own text box or a second time to convert text blocks to shapes. After text is converted to shapes, it is no longer recognized as text and cannot be edited as text. With text broken apart, Flash allows you to quickly distribute the character blocks to separate layers. Select the text blocks with the Arrow tool and then choose Modify, Timeline, Distribute to Layers . Flash places each letter on a separate layer, named for each character. Naming Distributed Layers Flash assigns each distributed layer the name of the letter it contains. If a word uses a letter more than once, you end up with several layers with the same name. This quickly becomes confusing, so be sure to add numbers or otherwise create distinctions between layers containing the same letters . | Transforming Text After your text is broken apart into shapes, it can be dramatically transformed. You can use the Subselection tool to select points and move them, changing the shapes of letters, as shown in Figure 17.8. Such transformations can be used to create unique letter shapes and can be animated over time through the use of shape tweens. Figure 17.8. After your text is broken apart into shapes, you can use the Subselection tool to drag anchor points and reshape letters. For more information about creating animation and shape tweens, see Chapter 18, "Animation, Interactivity, and Rich Media," page 379 . You can also use the new Distort and Envelope transform modifiers to really push the boundaries of text distortion. You cannot use these modifiers on groups or symbols: These tools are grayed out until you convert the text to shapes. Then you use either the Arrow tool or the Free Transform tool and drag over shapes that create a word to transform the word as a whole. If you use the Arrow tool, select the Transform tool; then select the Distort or Envelope modifiers of the Free Transform tool at the bottom of the Toolbox, and select and drag the transform handles that appear around your word, as shown in Figure 17.9. Figure 17.9. Use the Distort modifier of the Free Transform tool to create perspective text effects. The Envelope modifier creates the most dramatic transformation and can completely change the shapes of letters, as shown in Figure 17.10. Use this powerful capability carefully because letters can become so misshapen that they are no longer recognizable or legible. Figure 17.10. Use the Envelope modifier of the Free Transform tool for more psychedelic text effects. |