Actionscript 3.0 flash.text textformat textformat help.adobe.com livedocs.adobe.com
This model provides a clearer and more efficient mechanism than the event systems available in previous versions of ActionScript. Events and error events are located in the flash. The Flash Professional components and Flex framework use the same event model, so the event system is unified across the Flash Platform.
The API for accessing the display list—the tree that contains any visual elements in the application—consists of classes for working with visual primitives. The Sprite class is a lightweight building block, designed to be a base class for visual elements such as user interface components.
The Shape class represents raw vector shapes. These classes can be instantiated naturally with the new operator and can be dynamically reparented at any time. Depth management is automatic. Methods are provided for specifying and managing the stacking order of objects. The Loader class provides a single mechanism for loading SWF files and image assets and provides a way to access detailed information about loaded content. The URLLoaderclass provides a separate mechanism for loading text and binary data in data-driven applications.
The Socket class provides a means to read and write binary data to server sockets in any format. Various APIs provide low-level access to data.
For data that is being downloaded, the URLStream class provides access to data as raw binary data while it is being downloaded. The ByteArray class lets you optimize reading, writing, and working with binary data. Security APIs provide information about the security privileges of a SWF file or loaded content, enabling you to handle security errors.
The TextLineMetrics class provides detailed metrics for a line of text within a text field; it replaces the TextFormat. The TextField class contains low-level methods that provide specific information about a line of text or a single character in a text field. For example, the getCharBoundaries method returns a rectangle representing the bounding box of a character.
The getCharIndexAtPoint method returns the index of the character at a specified point. Bind expressions, which you can use to set field values. For more information on binding data, see Binding data in Flash forms. Your ActionScript code can be inline in the form attribute specification, you can make a call to a custom function that you define, or you can use the ActionScript includecommand in the attribute specification to get the ActionScript from a.
The following example shows a simple Fahrenheit to Celsius converter that does the conversion directly on the client, without requiring the user to submit a form to the ColdFusion server. Note: You do not use the text property for example, fieldname. Package flash. Related API Elements flash. Public Properties. Hide Inherited Public Properties. Show Inherited Public Properties. A reference to the class object or constructor function for a given object instance.
Public Methods. Parameters value : String — The string to replace the currently selected text. Two different TextField objects are created and event listeners are added for the MouseEvent. Mouse up occurs when the user releases the mouse, an event that normally happens after a selection of text is made.
Note that the default setting for a text field is for its text to be selected. In the mouseHandler1 method, when a user release a mouse in the myTextField1 text field, the text is erased by replacing it with an empty string. This can continue until all the text is erased. In the mouseHandler2 method, when a user selects some text in myTextField2 text field, properties selectionBeginIndex and selectionEndIndex are checked to see if any character was selected.
The selectionBeginIndex and selectionEndIndex properties don't have the same value if some text were selected. Replaces the range of characters that the beginIndex and endIndex parameters specify with the contents of the newText parameter. As designed, the text from beginIndex to endIndex-1 is replaced. Note: This method does not work if a style sheet is applied to the text field.
Parameters beginIndex : int — The zero-based index value for the start position of the replacement range. The outputText text field is set to automatically fit the text and to resize as a left-justified text. Note that with each call to the method appendText , the current text's begin and end index are changed.
Here, only the final text after the changes have been made will display. Sets as selected the text designated by the index values of the first and last characters, which are specified with the beginIndex and endIndex parameters. If the two parameter values are the same, this method sets the insertion point, as if you set the caretIndex property.
Parameters beginIndex : int — The zero-based index value of the first character in the selection for example, the first character is 0, the second character is 1, and so on.
Two event listeners for the myTextField text field respond to the user's mouse clicks or mouse up events. Mouse up will occur when the user releases the mouse, an event that normally happens after a selection of text is made.
When some text is clicked, clickHandler method is invoked. When some text is selected and the mouse is released, mouseUpHandler method is invoked.
Applies the text formatting that the format parameter specifies to the specified text in a text field. The value of format must be a TextFormat object that specifies the desired text formatting changes. Only the non-null properties of format are applied to the text field.
Any property of format that is set to null is not applied. By default, all of the properties of a newly created TextFormat object are set to null. The setTextFormat method changes the text formatting applied to a range of characters or to the entire body of text in a text field. To apply the properties of format to all text in the text field, do not specify values for beginIndex and endIndex. To apply the properties of the format to a range of text, specify values for the beginIndex and the endIndex parameters.
You can use the length property to determine the index values. The two types of formatting information in a TextFormat object are character level formatting and paragraph level formatting. Each character in a text field can have its own character formatting settings, such as font name, font size, bold, and italic. For paragraphs, the first character of the paragraph is examined for the paragraph formatting settings for the entire paragraph. Examples of paragraph formatting settings are left margin, right margin, and indentation.
Any text inserted manually by the user, or replaced by the replaceSelectedText method, receives the default text field formatting for new text, and not the formatting specified for the text insertion point.
To set the default formatting for new text, use defaultTextFormat. Parameters format : flash. As designed, if you specify beginIndex and endIndex values, the text from beginIndex to endIndex-1 is updated. Notice that any text inserted manually by the user, or replaced by the replaceSelectedText method, receives the default text field formatting for new text, and not the formatting specified for the text insertion point. To set a text field's default formatting for new text, use the defaultTextFormat property.
An event listener for the myTextField text field is added to respond to the mouse clicks by invoking the clickHandler method. In the clickHandler method, the getTextFormat method returns the current format of a character index 55 from the intended range of the text, which is then placed in the currentTextFormat TextFormat object. The if statement checks the currentTextFormat text format to see if the character in the range is using the new format font point is set to If the character in the range is using the new format, the format of the range is set back to the default original format of the text field.
Dispatched after a control value is modified, unlike the textInput event, which is dispatched before the value is modified. For example, if a user types text into a text field, a change event is dispatched after every keystroke. Two text fields are created, one for the user input and the other headingTextField for the copy of the user input. A TextFormat object is also created and the default text format is assigned to the headingTextField text field.
When the content of the text field is changed, the changeHandler method is invoked, which assigns the text in the inputTextField text field to the headingTextField text field. If the method was called for the TextEvent.
Note: The default behavior, adding the text to the text field, occurs only when Flash Player generates the event, which in this case happens when a user attempts to input text. You cannot put text into a text field by sending it textInput events. Flash Player dispatches the textInput event when a user enters one or more characters of text.
Various text input methods can generate this event, including standard keyboards, input method editors IMEs , voice or speech recognition systems, and even the act of pasting plain text with no formatting or style information. Flash Player dispatches the textInteractionModeChange event when a user changes the interaction mode of a text field. Filters: Retrieving Data from Server Retrieving Data from Server Classes x.
Package flash. You can give a text field an instance name in the Property inspector and use the methods and properties of the TextField class to manipulate it with ActionScript. To create a text field dynamically, use the TextField constructor. Use native features with a soft keyboard Display programming Basics of display programming Core display classes Choosing a DisplayObject subclass Basics of Working with text Using the TextField class Displaying text Advanced text rendering.
TextFormat flash. StyleSheet htmlText. Public Properties. Hide Inherited Public Properties. Show Inherited Public Properties. The current accessibility implementation AccessibilityImplementation for this InteractiveObject instance. The current accessibility options for this display object.
Indicates the alpha transparency value of the object specified. A value from the BlendMode class that specifies which blend mode to use. If set to true, Flash runtimes cache an internal bitmap representation of the display object. If non-null, this Matrix object defines how a display object is rendered when cacheAsBitmap is set to true. A reference to the class object or constructor function for a given object instance.
An indexed array that contains each filter object currently associated with the display object. The calling display object is masked by the specified mask object. Obtains the meta data object of the DisplayObject instance if meta data was stored alongside the the instance of this DisplayObject in the SWF file through a PlaceObject4 tag. Specifies whether this object receives mouse, or other user input, messages. Specifies whether a virtual keyboard an on-screen, software keyboard should display when this InteractiveObject instance receives focus.
Specifies whether the display object is opaque with a certain background color. Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Indicates the x-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. Indicates the y-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container.
Indicates the z-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. Indicates the horizontal scale percentage of the object as applied from the registration point. Indicates the vertical scale percentage of an object as applied from the registration point of the object. Indicates the depth scale percentage of an object as applied from the registration point of the object.
Defines the area that should remain on-screen when a soft keyboard is displayed not available on iOS. An object with properties pertaining to a display object's matrix, color transform, and pixel bounds. Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent DisplayObjectContainer. Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent DisplayObjectContainer.
Indicates the z coordinate position along the z-axis of the DisplayObject instance relative to the 3D parent container. Public Methods. Hide Inherited Public Methods. Show Inherited Public Methods. Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
Returns a rectangle that is the bounding box of the character. Given a character index, returns the index of the first character in the same paragraph. Returns the number of characters in a specific text line. Returns the text of the line specified by the lineIndex parameter. Returns a rectangle that defines the boundary of the display object, based on the coordinate system defined by the targetCoordinateSpace parameter, excluding any strokes on shapes.
Converts the point object from the Stage global coordinates to the display object's local coordinates. Converts a two-dimensional point from the Stage global coordinates to a three-dimensional display object's local coordinates.
Checks whether the EventDispatcher object has any listeners registered for a specific type of event. Indicates whether an object has a specified property defined. Evaluates the bounding box of the display object to see if it overlaps or intersects with the bounding box of the obj display object.
Evaluates the display object to see if it overlaps or intersects with the point specified by the x and y parameters. Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. Converts a three-dimensional point of the three-dimensional display object's local coordinates to a two-dimensional point in the Stage global coordinates.
Converts the point object from the display object's local coordinates to the Stage global coordinates. Indicates whether the specified property exists and is enumerable. Sets the availability of a dynamic property for loop operations. Returns the string representation of this object, formatted according to locale-specific conventions. Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
Click for more information on events. Hide Inherited Events. Show Inherited Events. Property Detail. Compile and run the following file. When you run the file, drag to select text in each of the two text fields, and notice the difference in selection highlighting when you select text in the two text fields changing focus : Copy. To set values for this property, use the following string values: String value Description flash. This value matches the type of anti-aliasing that Flash Player 7 and earlier versions used.
This feature became available in Flash Player 8. Advanced anti-aliasing allows for high-quality rendering of font faces at small sizes. It is best used with applications with a lot of small text. Advanced anti-aliasing is not recommended for fonts that are larger than 48 points. AntiAliasType flash. Implementation public function get autoSize : String public function set autoSize value: String : void Throws ArgumentError — The autoSize specified is not a member of flash.
Related API Elements flash. TextFieldAutoSize flash. Implementation public function get background : Boolean public function set background value: Boolean : void Related API Elements flash. Implementation public function get backgroundColor : uint public function set backgroundColor value: uint : void Related API Elements flash. In this example, a TextField instance is created and populated with text.
An event listener is assigned so that when the user clicks on the TextField, the printCursorPosition method is called. In that case, the values of the caretIndex , selectionBeginIndex , and selectionEndIndex properties are output.
Set the condenseWhite property before setting the htmlText property. The following shows the difference between setting the condenseWhite setting to false and setting it to true : Copy. Note: You can't set this property if a style sheet is applied to the text field.
Implementation public function get defaultTextFormat : flash. Implementation public function get displayAsPassword : Boolean public function set displayAsPassword value: Boolean : void.
For the flash. GridFitType property, you can use the following string values: String value Description flash. NONE Specifies no grid fitting. Horizontal and vertical lines in the glyphs are not forced to the pixel grid. This setting is recommended for animation or for large font sizes.
This setting works only for left-aligned text fields. To use this setting, the flash. AntiAliasType property of the text field must be set to flash.
This setting generally provides the best legibility for left-aligned text. The flash. SUBPIXEL setting is often good for right-aligned or centered dynamic text, and it is sometimes a useful trade-off for animation versus text quality.
The default value is pixel. GridFitType flash. The following example shows three text fields with different settings for the gridFitType property. When you use this example, notice the difference in legibility for the first two lines. Also note the optimal use of GridFitType.
To specify a link event, use the event scheme instead of the http scheme in your href attribute. You can then create an ActionScript function that executes whenever the link TextEvent is dispatched.
You can also define a:link , a:hover , and a:active styles for anchor tags by using style sheets. A bold typeface must be available for the font used. Set the text field to be a multiline text field to use this tag. As shown in the following example, you can specify a list of comma-delimited font names, in which case Flash Player selects the first available font.
If the specified font is not installed on the local computer system or isn't embedded in the SWF file, Flash Player selects a substitute font. Text automatically flows around images you embed in text fields.
0コメント