Flash Dynamic Text

Flash Dynamic Text

Flash Dynamic Text Tutorial

Flash

Flash Dynamic Text Box

1 Open a new Flash document. 2 Select the Text tool (T). Go to the Property inspector panel below the scene and make the following choices (the list numbers correspond to the ones seen in the screenshot below): In the menu that defines the type of your text field, on the left, select Dynamic Text. This one covers the creation of dynamic text visuals. I’ll go explain how to tap into the “statement” variable within Flash so you can create your own text based clips. I’ll also touch on the “duration” and “position” variables, which if used properly, allow playback speed adjustment of code based animations. Anti-aliasing is supported for static, dynamic, and input text if the user has Flash® Player 7 or later. It is supported only for static text if the user has an earlier version of Flash Player. When using small text in a Animate document, keep in mind the following guidelines. How to input a name and then display it in Flash CS6 using actionscript 3.0. For more visit raypastore.com. In this movie, Perkins brother Todd shows you how to format the text that you learned how to dynamically loaded last time. It's actually cooler than it sounds.

Flash display dynamic textFlash dynamic text files

Flash Player 9 and later, Adobe AIR 1.0 and later

Flash Dynamic Text

Although authoring tools like Adobe Flash Builder and Flash Professional provide several options for displaying text, including text-related components or text tools, the simplest way to display text programmatically is through a text field.

Types of text

The type of text within a text field is characterized by its source:

  • Dynamic text

    Dynamic text includes content that is loaded from an external source, such as a text file, an XML file, or even a remote web service.

  • Input text

    Input text is any text entered by a user or dynamic text that a user can edit. You can set up a style sheet to format input text, or use the flash.text.TextFormat class to assign properties to the text field for the input content. For more information, see Capturing text input .

  • Static text

    Static text is created through Flash Professional only. You cannot create a static text instance using ActionScript 3.0. However, you can use ActionScript classes like StaticText and TextSnapshot to manipulate an existing static text instance. For more information, see Working with static text .

Modifying the text field contents

You can define dynamic text by assigning a string to the flash.text.TextField.text property. You assign a string directly to the property, as follows:

You can also assign the text property a value from a variable defined in your script, as in the following example:

Alternatively, you can assign the text property a value from a remote variable. You have three options for loading text values from remote sources:

  • The flash.net.URLLoader and flash.net.URLRequest classes load variables for the text from a local or remote location.

  • The FlashVars attribute is embedded in the HTML page hosting the SWF file and can contain values for text variables.

  • The flash.net.SharedObject class manages persistent storage of values. For more information, see Storing local data .

Displaying HTML text

The flash.text.TextField class has an htmlText property that you can use to identify your text string as one containing HTML tags for formatting the content. As in the following example, you must assign your string value to the htmlText property (not the text property) for Flash Player or AIR to render the text as HTML:

Flash Player and AIR support a subset of HTML tags and entities for the htmlText property. The flash.text.TextField.htmlText property description in the ActionScript 3.0 Reference provides detailed information about the supported HTML tags and entities.

Once you designate your content using the htmlText property, you can use style sheets or the textformat tag to manage the formatting of your content. For more information, see Formatting text .

Using images in text fields

Another advantage to displaying your content as HTML text is that you can include images in the text field. You can reference an image, local or remote, using the img tag and have it appear within the associated text field.

The following example creates a text field named myTextBox and includes a JPG image of an eye, stored in the same directory as the SWF file, within the displayed text:

The img tag supports JPEG, GIF, PNG, and SWF files.

Scrolling text in a text field

In many cases, your text can be longer than the text field displaying the text. Or you may have an input field that allows a user to input more text than can be displayed at one time. You can use the scroll-related properties of the flash.text.TextField class to manage lengthy content, either vertically or horizontally.

The scroll-related properties include TextField.scrollV , TextField.scrollH and maxScrollV and maxScrollH . Use these properties to respond to events, like a mouse click or a keypress.

The following example creates a text field that is a set size and contains more text than the field can display at one time. As the user clicks the text field, the text scrolls vertically.