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 .. 188 189 190 191 192 193 < 194 > 195 196 197 198 199 200 .. 427 >> Next

397
398 Part V ♦ The Movie Classes
at the line type, selectable, HTML-enabled, border, and maximum character settings. In this section you’ll get a chance to see how to modify those settings in the Property inspector. The corresponding ActionScript properties are discussed later in the chapter.
The Line type menu allows you to select from the following options:
♦ Single line: This default setting allows only one line of text to be typed into the input text. However, in the unlikely event that you need to assign text to this field using ActionScript expressions, you can use the newline operator (or \n backslash, discussed later) to force a carriage return in the field.
♦ Multiline: This setting allows several lines of text to be typed into the field, and automatically wraps each line of text.
♦ Multiline no wrap: This setting allows several lines of text to be entered into the field by the user, but only pressing the Enter or Return key starts a new line of text. Text does not automatically wrap if the user types beyond the length of the text field.
♦ Password: You can hide the user’s input from displaying by using this option. Each typed character is seen as an asterisk (*), just like most password fields in other common user interfaces. However, if you access the field’s value in ActionScript expressions, the actual typed characters are available.
Immediately to the right of the Line type menu, you find other options that control the formatting of the editable text field. The first option, Selectable, if enabled, allows users to highlight text within a TextField object in order to copy it and paste it into another field (or external document). To the right of the Selectable option is the Enable HTML option, which allows you to use HTML formatting tags within your editable TextField object when you assign the value via ActionScript. Just to the right of the HTML option is the Show border option. When enabled, this option automatically formats an input text field with a white background and black hairline border. If you do not enable the Show border option, the Flash Player displays the TextField object with a dashed outline during authoring time. This outline is not visible when you publish your movie and view it in the Flash Player.
Make sure that the text color is one that will stand out. A common mistake is to have white text on a white background. When that occurs, obviously the text will not seem to be visible, even though it is. Should you notice that your text does not seem to appear, make sure that the color is set correctly.
On the far right of the Property inspector, you find a field labeled Maximum Characters. This option allows you specify a limit to the number of characters that can be typed into the input text field. By default, it is set to zero (0), which means that an unlimited number of characters can be typed into the field.
Making Runtime Text
Runtime text refers to a TextField object that you create using ActionScript code instead of using the Text tool during authoring time. Although authoring time text has its benefits, it does not allow you the same programmatic control that runtime text can provide. Runtime text provides such benefits as the following:
♦ Runtime text can be created based on content that is loaded from external sources such as XML files and databases.
Chapter 17 ♦ The TextField and Selection Classes 399
♦ Runtime text can be created based on user interaction.
♦ When you have sequences of text you want to create, runtime text can provide a more efficient way of adding it rather than trying to add it at authoring time.
There is just one technique for creating runtime text — regardless of whether you want it to be used for input or as dynamic text. The createTextField() method can be called from any MovieClip object in order to create a new TextField object nested within it. The createTextField() method requires six parameters: instance name, depth, x, y, width, and height. So, for example, to create a new TextField object named tLabel within the current MovieClip object you could use the following code:
this.createTextField("tLabel", this.getNextHighestDepth(), 0, 0, 100, 20);
The preceding code creates the new TextField object with the next highest depth, places it at 0,0, and sizes it to 100 by 20 pixels.
Tip The createTextField() method does not return a reference to the newly created
TextField instance — something that you might expect given how methods such as
jf attachMovie() and duplicateMovieClip() work.
By default, when you create a new runtime TextField object its properties are as follows:
autoSize= "none" maxChars=null
background = false multiline = false
BackgroundColor= password=false
0xFFFFFF
restrict = null
border = false
selectable = true
borderColor=0x000000 „„„„„„
textColor = 0x000000
condenseWhite = false
type = "dynamic"
embedFonts = false
variable = null
html = false
wordwrap = false
Previous << 1 .. 188 189 190 191 192 193 < 194 > 195 196 197 198 199 200 .. 427 >> Next