Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Flash MX action script bible - Reinhardt R.

Reinhardt R. Flash MX action script bible - Wiley & sons , 2004. - 987 p.
ISBN: 0-7645-4354-7
Download (direct link): macractionscriptbiblefeb2004.pdf
Previous << 1 .. 208 209 210 211 212 213 < 214 > 215 216 217 218 219 220 .. 427 >> Next

Enabling and Disabling Tab-Initiated Focus
You can use the tabEnabled property to determine whether pressing the Tab key can bring focus to the text. By default the property is true, meaning that the instance can receive focus initiated by pressing the Tab key. Typically, input text should be Tab-enabled. But dynamic text likely should not be Tab-enabled.
Changing Tab Order
The tablndex property allows you to determine the order in which objects are accessed with the Tab key. Any positive integer can be used for the value of the tablndex property. Lower numbers are accessed in ascending order — an object with a tablndex value of 1 is the first object that will be focused before an object with a tablndex value of 2. As soon as you’ve assigned a tablndex value to any object current visible on the stage, the Tab order is determined solely by the tablndex values for the visible objects. If an object does not have a tablndex property value, it is not included in the sequence.
The following code creates three input TextField objects. The tEmail and tPostalCode objects are assigned tablndex property values, whereas the tComments object is not. If you test the code, you’ll see that you can use the Tab key to change focus between tEmail and tPostalCode. However, in order to bring focus to the tComments field you have to click in the field.
this.createTextField("tEmail", 1, 25, 35, 100, 20); tEmail.border = true;
440 Part V ♦ The Movie Classes
tEmail.type = "input"; tEmail.tablndex = 1;
this.createTextField("tPostalCode", 2, 150, 35, 200, 20); tPostalCode.border = true; tPostalCode.type = "input"; tPostalCode.tabIndex = 2;
this.createTextField("tComments", 3, 25, 75, 325, 200); tComments.border = true; tComments.type = "input";
If you append the following line of code to the preceding, you can see that by setting the tablndex property for tComments, tComments is included in the sequence:
tComments.tablndex = 3;
TextField, MovieClip, and Button objects have the tablndex property. For more information, read the coverage of tablndex i n Chapter 9.
Web We'd like to know what you thought about this chapter. Visit www.flashsupport.com
Resource /feedback to fill out an online form with your comments.
Summary
♦ Text in Flash is classified as static, dynamic, or input. Dynamic and input text are the types of text you’ll work with when using ActionScript.
♦ You can create TextField objects at authoring time using the Text tool or at runtime using the createTextField() method.
♦ Using the basic properties of the TextField class, you can control aspects of object such as the text that is displayed, word wrapping, text color, and more.
♦ Flash text can render some HTML tags, enabling you to add formatting and hyperlinks and even to embed content.
♦ You can scroll text vertically and horizontally using the built-in scrolling properties.
♦ Focus refers to the active portion of an application. You can get and set focus within a Flash application using the Selection.getFocus() and Selection.setFocus() methods.
♦ The Selection class also enables you to get and set the selected text within the focused TextField object.
♦ Using the tabEnabled and tablndex properties you can determine how the Tab key affects focus within the application.
♦♦♦
Using the TextFormat Object and Style Sheets
In the Chapter 17, you learned all about working with text with ActionScript. In this chapter, you’ll look at how you can use ActionScript to then format that text. Although you did see how you could use HTML to apply some basic formatting to your text in Chapter 17, this chapter discusses how you can apply more detailed formatting using the TextFormat and StyleSheet classes.
Working with TextFormat
The TextFormat class was introduced in Flash MX, so it is not new to Flash MX 2004. You can use the TextFormat class to apply formatting to TextField objects’ contents for Flash 6 and Flash 7 applications. The TextFormat class enables you to specify the following formatting options:
♦ Alignment
♦ Margins
♦ Indentation
♦ Block indentation
♦ Tab stops
♦ Line spacing (called “leading”)
♦ Bolded text
♦ Italicized text
♦ Underlined text
♦ Bullet points
♦ Text color
♦ Font face
♦ Font size
A P
•j
8
♦ ♦ ♦ ♦ In This Chapter
Applying formatting to text using a TextFormat object
Understanding the formatting properties for the TextFormat class
Working with cascading style sheets (CSS) in ActionScript
Creating CSS with ActionScript
Loading external CSS files
♦♦♦♦
♦ Hyperlinks and target windows
442 Part V ♦ The Movie Classes
You can adjust the formatting options for part or all of the content of a TextField object.
Creating a TextFormat Object
One of the obvious things that you need to do before you can apply any formatting is create the TextFormat object that you’ll use. You can create a TextFormat object with the constructor. The most common way is to call the constructor with no parameters. For example:
Previous << 1 .. 208 209 210 211 212 213 < 214 > 215 216 217 218 219 220 .. 427 >> Next