flash.text.engineTextLine The TextLine class is used to display text on the display list.flash.display:DisplayObjectContainer The TextLine class is used to display text on the display list.

You cannot create a TextLine object directly from ActionScript code. If you call new TextLine(), an exception is thrown. To create a TextLine object, call the createTextLine() method of a TextBlock.

The TextLine encapsulates the minimum information necessary to render its contents and to provide interactivity through some methods that describe the properties of the atoms of the line. The term atom refers to both graphic elements and characters (including groups of combining characters), the indivisible entities that make up a text line.

After normal event-dispatching for a text line finishes, if the line is valid, events are mirrored to the event dispatchers that are specified in the eventMirror properties of the content element objects that contributed to the text line. These objects are recorded in the TextLine.mirrorRegions property. The events are not mirrored if event propagation failed or was stopped, or if the text line is not valid.

Mirroring of mouse events is a special case. Because mirror regions aren't actually display objects, mouseOver and mouseOut events are simulated for them. rollOver and rollOut events are not simulated. All naturally occurring mouseOver, mouseOut, rollOver and rollOut events (whether targeted at the text line or at children of the text line) are ignored - they are not mirrored.

The origin of a text line object is the beginning of the baseline. If you don't set the vertical position (y property) of a line that contains Latin text on a Roman baseline, only the descenders of the text appear below the top of the Sprite to which you add the text line. See the following diagram:

The TextLine class has several ancestor classes — DisplayObjectContainer, InteractiveObject, DisplayObject, and EventDispatcher — from which it inherits properties and methods. The following inherited properties are inapplicable to TextLine objects:

  • contextMenu
  • focusRect
  • tabChildren
  • tabEnabled
  • tabIndex

If you try to set these properties, the text engine throws the error: IllegalOperationError. You can read these properties, but they always contain default values.

This example displays various text lines and steps through the atoms in a text block, using getAtomBounds() to frame each one.
  1. Add the NumericStepper component to the library.
  2. Save this code as TextLineExample.as in the same directory as your FLA.
  3. Set the Class in the Properties window of the FLA to TextLineExample.
package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; import flash.text.engine.FontDescription; import flash.text.engine.FontPosture; import flash.text.engine.FontWeight; import fl.controls.NumericStepper; import flash.events.Event; import flash.geom.Rectangle; public class TextLineExample extends Sprite { private var atomStepper:NumericStepper = new NumericStepper(); private var atomDataContainer:Sprite; private var fontDescriptionItalic:FontDescription = new FontDescription("Arial", FontWeight.NORMAL, FontPosture.ITALIC); private var fontDescriptionNormal:FontDescription = new FontDescription("Arial", FontWeight.NORMAL , FontPosture.NORMAL); private var textBlock:TextBlock = new TextBlock(); private var textLine:TextLine; public function TextLineExample():void { var myText:String = "I am a TextElement, created from a String and assigned " + "to the content property of a TextBlock. From the text block, " + "the createTextLine() method created these lines, 300 pixels wide, " + "for display." ; atomStepper.minimum = 0; atomStepper.value = 0; atomStepper.width = 50; addChild(atomStepper); atomStepper.x = 20; atomStepper.y = 120; atomStepper.addEventListener(Event.CHANGE, nsChange); var directions:String = "Click up / down arrows to frame atoms in text block above."; var formatItalic:ElementFormat = new ElementFormat(fontDescriptionItalic); formatItalic.fontSize = 12; var textElement1:TextElement = new TextElement(directions, formatItalic); textBlock.content = textElement1; createLines(textBlock, 15, 160, 400, this); var formatNormal:ElementFormat = new ElementFormat(fontDescriptionNormal); formatNormal.fontSize = 16; var textElement2:TextElement = new TextElement(myText, formatNormal); textBlock.content = textElement2; createLines(textBlock, 15.0, 20.0, 300, this); textLine = textBlock.firstLine; atomStepper.maximum = textLine.atomCount - 1; showAtom(textLine, 0); } private function nsChange(event:Event):void { removeAtom(textLine); if (atomStepper.value == textLine.atomCount - 1) { if(textLine != textBlock.lastLine) { textLine = textLine.nextLine; atomStepper.maximum = textLine.atomCount - 1; atomStepper.value = 0; } } showAtom(textLine, atomStepper.value); } private function createLines(textBlock, startX, startY, width, container) { var textLine:TextLine = textBlock.createTextLine (null, width); while (textLine) { textLine.x = startX; textLine.y = startY; startY += textLine.height + 2; container.addChild(textLine); textLine = textBlock.createTextLine (textLine, width); } } private function showAtom(textLine, i):void { var box:Sprite = new Sprite(); var mcGraphics = box.graphics; var bounds:Rectangle = textLine.getAtomBounds(i); mcGraphics.lineStyle(1, 0xFF0000, 1.0); mcGraphics.drawRect(bounds.left, bounds.top, bounds.width, bounds.height); textLine.userData = textLine.addChild(box); displayAtomData(textLine,i); } private function displayAtomData(textLine, i) { if(atomDataContainer != null) removeChild(atomDataContainer); atomDataContainer=new Sprite(); var format = new ElementFormat(fontDescriptionNormal); format.color = 0x00000FF; var n:int = 0; var nxtY:Number = 0; var atomInfo:String = "value of getAtomBidiLevel() is: " + textLine.getAtomBidiLevel(i)+"\n" +"value of getAtomCenter() is: " + textLine.getAtomCenter(i)+"\n" +"value of getAtomIndexAtCharIndex() is: " + textLine.getAtomIndexAtCharIndex(i)+"\n" +"value of getAtomTextBlockBeginIndex() is: " + textLine.getAtomTextBlockBeginIndex(i)+"\n" +"value of getAtomTextBlockEndIndex() is: " + textLine.getAtomTextBlockEndIndex(i)+"\n" +"value of getAtomTextRotation() is: " + textLine.getAtomTextRotation(i)+"\n"; var atomtextBlock:TextBlock = new TextBlock(); var textElement3:TextElement = new TextElement(atomInfo, format); atomtextBlock.content = textElement3; createLines(atomtextBlock,20,200,500, atomDataContainer) addChild(atomDataContainer); } private function removeAtom(textLine):void { textLine.removeChild(textLine.userData); } } }
ContentElement.eventMirrorTextBlock.createTextLine()TextLineValiditydump Dumps the underlying contents of the TextLine as an XML string.String Dumps the underlying contents of the TextLine as an XML string. This can be useful in automated testing, and includes text, formatting, and layout information.

The following describes the output:

	 [LINE]
	 <line ascent=[Number] descent=[Number] rotation=[int]>
	 	<elements>
	 		[0-N ELEMENT]
	 	</elements>
	 	<clusters>
	 		[0-N CLUSTER]
	 	</clusters>
	 </line>
	 
	 [ELEMENT]
	 <glyph isEmbedded=[Boolean] fontName=[String] isBold=[Boolean] isItalic=[Boolean] gid=[int] pointSize=[Number] x=[Number] y=[Number] rotation=[int]/>
	 or
	 <graphic child=[int] x=[Number] y=[Number] rotation=[int]/>
	 or
	 <embeddedRun x=[Number] y=[Number]>
	 	[LINE]
	 </embeddedRun>
	 
	 [CLUSTER]
	 <cluster xLeft=[Number] xCenter=[Number] xRight=[Number] cursorOnLeft=[Boolean] cursorOnRight=[Boolean] wordBoundaryOnLeft=[Boolean] wordBoundaryOnRight=[Boolean]/>
	 

Note: The content and format of the output from this method could change in the future. Adobe does not guarantee backward compatibility for this method.

TextBlock.dump()
flushAtomData This method is deprecated and has no effect.Now does nothing This method is deprecated and has no effect. Atom data is compressed and is not a factor in managing memory efficiency. TextBlock.dump()getAtomBidiLevel Gets the bidirectional level of the atom at the specified index.The specified atom index is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe bidirectional level of the atom at atomIndex. intatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the bidirectional level of the atom at the specified index. Determined by a combination of TextBlock.bidiLevel and the Unicode bidirectional properties of the characters that form the line.

For example, if you start a text block with some Hebrew text, you set TextBlock.bidiLevel to 1, establishing a default of right to left. If within the text you have a quote in English (left to right), that text has an AtomBidiLevel of 2. If within the English you have a bit of Arabic (right to left), AtomBidiLevel for that run goes to 3. If within the Arabic a number (left to right) occurs, the AtomBidiLevel setting for the number is 4. It does not matter in which line the atoms end up; the Hebrew atoms are AtomBidiLevel 1, the English atoms are AtomBidiLevel 2, Arabic atoms are AtomBidiLevel 3, and the number atoms are AtomBidiLevel 4.

TextBlock.bidiLevel
getAtomBounds Gets the bounds of the atom at the specified index relative to the text line.The atom index specified is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe bounds of the atom at atomIndex. flash.geom:RectangleatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the bounds of the atom at the specified index relative to the text line. The bounds of the specified atom consist of its horizontal position (x) in the line, its vertical position in the line (y), its width (w), and its height (h). All values are in pixels. getAtomCenter Gets the center of the atom as measured along the baseline at the specified index.The atom index specified is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe center of the atom at atomIndex. NumberatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the center of the atom as measured along the baseline at the specified index. getAtomGraphic Gets the graphic of the atom at the specified index, or null if the atom is a character.The atom index specified is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe graphic of the atom at atomIndex. flash.display:DisplayObjectatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the graphic of the atom at the specified index, or null if the atom is a character. getAtomIndexAtCharIndex Returns the index of the atom containing the character specified by the charIndex parameter, or -1 if the character does not contribute to any atom in the line.The validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe index of the atom containing the character at charIndex. Returns -1 if the character does not contribute to any atom in the line. intcharIndexintThe zero-based index value of the character (for example, the first character is 0, the second character is 1, and so on). Returns the index of the atom containing the character specified by the charIndex parameter, or -1 if the character does not contribute to any atom in the line. The charIndex is relative to the entire contents of the text block containing the line. getAtomIndexAtPoint Returns the index of the atom at the point specified by the x and y parameters, or -1 if no atom exists at that point.The validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe index of the atom under the point. Returns -1 if the point is not over any atom. intstageXNumberThe global x coordinate of the point to test. stageYNumberThe global y coordinate of the point to test. Returns the index of the atom at the point specified by the x and y parameters, or -1 if no atom exists at that point.

This method takes global coordinates so that you can easily use it with MouseEvent.stageX and MouseEvent.stageY properties.

getAtomTextBlockBeginIndex Gets the text block begin index of the atom at the specified index.The atom index specified is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe text block begin index of the atom at atomIndex. intatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the text block begin index of the atom at the specified index. getAtomTextBlockEndIndex Gets the text block end index of the atom at the specified index.The atom index specified is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe text block end index of the atom at atomIndex. intatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the text block end index of the atom at the specified index. getAtomTextRotation Gets the rotation of the atom at the specified index.The specified atom index is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorThe rotation of the atom at atomIndex. StringatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Gets the rotation of the atom at the specified index. TextRotation constants are used for this property. The rotation of the atom is the cumulative rotations of the element and the line. Its primary use is for setting the orientation of the caret (cursor) when interacting with a TextLine. ElementFormat.textRotationgetAtomWordBoundaryOnLeft Indicates whether a word boundary occurs to the left of the atom at the specified index.The atom index specified is out of range. RangeErrorRangeErrorThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationErrorA Boolean value that indicates whether a word boundary occurs to the left of the atom at atomIndex. BooleanatomIndexintThe zero-based index value of the atom (for example, the first atom is 0, the second atom is 1, and so on). Indicates whether a word boundary occurs to the left of the atom at the specified index. Word boundaries are determined based on the Unicode properties of the characters which contributed to the line. getBaselinePosition Gets the position of the specified baseline, relative to TextBlock.baselineZero.If the baseline specified is not a member of TextBaseline. ArgumentErrorArgumentErrorThe position of the specified baseline relative to TextBlock.baselineZero. NumberbaselineStringThe baseline for which to retrieve the position. Use TextBaseline values. Gets the position of the specified baseline, relative to TextBlock.baselineZero. TextBlock.baselineZeroTextBaselinegetMirrorRegion Returns the first TextLineMirrorRegion on the line whose mirror property matches that specified by the mirror parameter, or null if no match exists.The first TextLineMirrorRegion on the line whose mirror property matches the specified value, or null if no match exists. flash.text.engine:TextLineMirrorRegionmirrorflash.events:EventDispatcherThe EventDispatcher mirror object to search for. Returns the first TextLineMirrorRegion on the line whose mirror property matches that specified by the mirror parameter, or null if no match exists.

Even a single TextElement can produce multiple TextLineMirrorRegion objects on one or more lines, depending on bidirectional level and line breaking. The nextRegion and previousRegion properties link all the mirror regions generated from one text element.

TextLineMirrorRegionContentElement.eventMirror
MAX_LINE_WIDTH The maximum requested width of a text line, in pixels.1000000int The maximum requested width of a text line, in pixels. The TextBlock.createTextLine() method uses this constant as the default value for the width parameter, if you do not specify a value. TextBlock.createTextLine()userData Provides a way for the application to associate arbitrary data with the text line. Provides a way for the application to associate arbitrary data with the text line. ascent Specifies the number of pixels from the baseline to the top of the tallest characters in the line.Number Specifies the number of pixels from the baseline to the top of the tallest characters in the line. For a TextLine that contains only a graphic element, ascent is set to 0. atomCount The number of atoms in the line, which is the number of indivisible elements, including spaces and graphic elements.intThe validity of the line is TextLineValidity.STATIC. IllegalOperationErrorflash.errors:IllegalOperationError The number of atoms in the line, which is the number of indivisible elements, including spaces and graphic elements. descent Specifies the number of pixels from the baseline to the bottom of the lowest-descending characters in the line.Number Specifies the number of pixels from the baseline to the bottom of the lowest-descending characters in the line. For a TextLine that contains only a graphic element, descent is set to 0. hasGraphicElement Indicates whether the text line contains any graphic elements.Boolean Indicates whether the text line contains any graphic elements. GraphicElementhasTabs Indicates whether the text line contains any tabs.Boolean Indicates whether the text line contains any tabs. mirrorRegions A Vector containing the TextLineMirrorRegion objects associated with the line, or null if none exist. A Vector containing the TextLineMirrorRegion objects associated with the line, or null if none exist. ContentElement.eventMirrorTextLineMirrorRegionnextLine The next TextLine in the TextBlock, or null if the current line is the last line in the block or the validity of the line is TextLineValidity.STATIC.flash.text.engine:TextLine The next TextLine in the TextBlock, or null if the current line is the last line in the block or the validity of the line is TextLineValidity.STATIC. previousLinepreviousLine The previous TextLine in the TextBlock, or null if the line is the first line in the block or the validity of the line is TextLineValidity.STATIC.flash.text.engine:TextLine The previous TextLine in the TextBlock, or null if the line is the first line in the block or the validity of the line is TextLineValidity.STATIC. nextLinerawTextLength The length of the raw text in the text block that became the line, including the U+FDEF characters representing graphic elements and any trailing spaces, which are part of the line but not are displayed.int The length of the raw text in the text block that became the line, including the U+FDEF characters representing graphic elements and any trailing spaces, which are part of the line but not are displayed. TextBlockContentElement.rawTextspecifiedWidth The width that was specified to the TextBlock.createTextLine() method when it created the line.Number The width that was specified to the TextBlock.createTextLine() method when it created the line. This value is useful when deciding if a change requires rebreaking the line. TextBlock.createTextLine()textWidthunjustifiedTextWidthtextBlockBeginIndex The index of the first character of the line in the raw text of the text block.int The index of the first character of the line in the raw text of the text block. TextBlocktextBlock The TextBlock containing this text line, or null if the validity of the line is TextLineValidity.STATIC, meaning that the connection between the line and the TextBlock has been severed.flash.text.engine:TextBlock The TextBlock containing this text line, or null if the validity of the line is TextLineValidity.STATIC, meaning that the connection between the line and the TextBlock has been severed. TextBlockTextLineValiditytextHeight The logical height of the text line, which is equal to ascent + descent.Number The logical height of the text line, which is equal to ascent + descent. To get the inked height, access the inherited height property.

The value is calculated based on the difference between the baselines that bound the line, either ideo top/bottom or ascent/descent depending on whether TextBlock.baselineZero is ideo or not. Graphic elements are not considered when computing these baselines.

DisplayObject.height
textWidth The logical width of the text line, which is the width that the text engine uses to lay out the line.Number The logical width of the text line, which is the width that the text engine uses to lay out the line. Access the inherited width property to get the actual width of the bounding box of all the drawn pixels. This example displays a line once in normal posture and once in italic, and traces the values of the specifiedWidth, textWidth and width properties in each case. The trace output is:
  • specifiedWidth is: 500
  • textWidth is: 268.9921875
  • width is: 269
  • specifiedWidth is: 500
  • textWidth is: 267.52734375
  • width is: 267.55
package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.FontDescription; import flash.text.engine.ElementFormat; import flash.text.engine.FontPosture; public class TextLine_textWidthExample extends Sprite { public function TextLine_textWidthExample() { var str:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "; var yPos:Number = 20; var fontDescription:FontDescription = new FontDescription(); var textBlock:TextBlock = new TextBlock(); fontDescription.fontPosture = FontPosture.NORMAL; var format:ElementFormat = new ElementFormat(fontDescription, 12); var textElement:TextElement = new TextElement(str, format); textBlock.content = textElement; createLine(textBlock, yPos); var fontDescriptionItalic = fontDescription.clone(); fontDescriptionItalic.fontPosture = FontPosture.ITALIC; var formatItalic = new ElementFormat(fontDescriptionItalic, 12); textElement = new TextElement(str, formatItalic); textBlock.content = textElement; createLine(textBlock, yPos + 20); } private function createLine(textBlock:TextBlock, yPos:Number):void { var textLine:TextLine = textBlock.createTextLine (null, 500); trace("specifiedWidth is: " + textLine.specifiedWidth); trace("textWidth is: " + textLine.textWidth); trace("width is: " + textLine.width); addChild(textLine); textLine.x = 15; textLine.y = yPos; } } }
specifiedWidthDisplayObject.width
totalAscent Specifies the number of pixels from the baseline to the top of the tallest character or graphic in the line.Number Specifies the number of pixels from the baseline to the top of the tallest character or graphic in the line. totalDescent Specifies the number of pixels from the baseline to the bottom of the lowest-descending character or graphic in the line.Number Specifies the number of pixels from the baseline to the bottom of the lowest-descending character or graphic in the line. totalHeight The total logical height of the text line, which is equal to totalAscent + totalDescent.Number The total logical height of the text line, which is equal to totalAscent + totalDescent. unjustifiedTextWidth The width of the line if it was not justified.Number The width of the line if it was not justified. For unjustified text, this value is the same as textWidth. For justified text, this value is what the length would have been without justification, and textWidth represents the actual line width. For example, when the following String is justified and submitted to TextBlock.createTextLine() with a width of 500, it has an actual width of 500 but an unjustified width of 268.9921875. When the String in the following example is justified and submitted to TextBlock.createTextLine() with a width of 500, it gets an actual width of 500 but has an unjustified width of 268.9921875. import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.FontDescription; import flash.text.engine.ElementFormat; import flash.text.engine.SpaceJustifier; import flash.text.engine.LineJustification; var str:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "; var fontDescription:FontDescription = new FontDescription(); var textBlock:TextBlock = new TextBlock(); var format:ElementFormat = new ElementFormat(fontDescription, 12); var textElement:TextElement = new TextElement(str, format); textBlock.content = textElement; var spaceJustifier:SpaceJustifier = new SpaceJustifier("en", LineJustification.ALL_INCLUDING_LAST); textBlock.textJustifier = spaceJustifier; var textLine:TextLine = textBlock.createTextLine(null, 500); textLine.y = 20; addChild(textLine); trace("textWidth value is: " + textLine.textWidth); // 500.00244140625 trace("unjustifiedTextWidth is: " + textLine.unjustifiedTextWidth); // 268.9921875 EastAsianJustifierLineJustificationSpaceJustifierspecifiedWidthtextWidthvalidity Specifies the current validity of the text line.StringIf current value is TextLineValidity.STATIC. ArgumentErrorArgumentErrorIf current value is TextLineValidity.INVALID and new value is anything other than TextValidity.STATIC. ArgumentErrorArgumentErrorIf current value is TextLineValidity.POSSIBLY_INVALID and new value is TextLineValidity.VALID. ArgumentErrorArgumentErrorIf new value is TextLineValidity.POSSIBLY_INVALID. ArgumentErrorArgumentError Specifies the current validity of the text line. Values for this property are found in the members of the TextLineValidity class. The rules for setting this property are as follows:

A line is considered USER_INVALID if validity is set to any string which is not a member of TextLineValidity. USER_INVALID is an abstraction used here to represent any such value.

When the contents of the TextBlock are modified, the Flash runtime marks affected text lines, the previous line, and all following lines as INVALID. The previous line must be marked invalid when a change allows the previous line to absorb part of the content that was originally on the first affected line.

Newly broken lines are always VALID. The Flash runtime may change lines that follow from VALID to POSSIBLY_INVALID or INVALID. It may change POSSIBLY_INVALID lines to VALID if the line breaks match up, or to INVALID if they don't.

Application code can mark VALID lines as INVALID or USER_INVALID, and can mark USER_INVALID lines as VALID. Application code cannot mark lines POSSIBLY_INVALID.

Application code can mark any line STATIC. Doing so causes the block member to become null. Any graphic elements in a STATIC text line are removed and reparented if they are part of a new text line broken from the text block from which the STATIC text line originally derived.

TextBlock.firstInvalidLineTextLineValidity
TabStop The TabStop class represents the properties of a tab stop in a text block.Object The TabStop class represents the properties of a tab stop in a text block. You assign tab stops as a Vector of TabStop objects to the TextBlock.tabStops property.

Setting the properties of a TabStop object after you apply it to a TextBlock does not invalidate the TextBlock.

This example illustrates the effects of the four tab stop alignment settings - START, CENTER, DECIMAL, and END. package { import flash.text.engine.*; import flash.display.Sprite; public class TabStopExample extends Sprite { public function TabStopExample():void { var container:Sprite = new Sprite(); var english:ElementFormat = new ElementFormat(); english.fontDescription = new FontDescription("Arial"); english.fontSize = 16; english.locale = "en"; var tabStops:Vector.<TabStop> = new Vector.<TabStop>(); tabStops.push( new TabStop(TabAlignment.START, 20), new TabStop(TabAlignment.CENTER, 120), new TabStop(TabAlignment.DECIMAL, 220, "."), new TabStop(TabAlignment.END, 320) ); var textBlock:TextBlock = new TextBlock(); textBlock.content = new TextElement( "\tstart\tcenter\tdeci.mal\tend\n" + "\tl\tl\t3.4\tl\n" + "\tlm\tlm\t234.56\tlm\n" + "\tlmn\tlmn\t12345678.34567\tlmn\n" , english); textBlock.tabStops = tabStops; var y:Number = 60; var previousTextLine:TextLine = null; var textLine:TextLine; var i:int; var tabOrigin:Number = 100; for (i = 0; i < 4; i++) { textLine = textBlock.createTextLine(previousTextLine, 1000, 0); textLine.x = 20; textLine.y = y; container.addChild(textLine); y += 25; previousTextLine = textLine; } addChild(container); } } }
TextBlock.tabStopsTabAlignmentTabStop Creates a new TabStop.The alignment specified is not a member of TabAlignment. ArgumentErrorArgumentErroralignmentStringstartThe tab alignment type of this tab stop. Valid values for this property are found in the members of the TabAlignment class. The default value is TabAlignment.START. positionNumber0.0The position of the tab stop, in pixels. The default value is 0.0. decimalAlignmentTokenStringThe alignment token to be used if the alignment is TabAlignment.DECIMAL, The default value is "". Creates a new TabStop. TabAlignmentalignment Specifies the tab alignment for this tab stop.StringIf set to any value that is not a member of TabAlignment. ArgumentErrorArgumentError Specifies the tab alignment for this tab stop. Use the constants in the TabAlignment class to set this property.

The default value is TabAlignment.START.

Use the lineOffset argument to TextBlock.createTextLine() to adjust the tabs if the origin of the line does not align with other lines that share the same tab stops.

Use the following constants from the TabAlignment class to set the value for this property:

String valueDescriptionTabAlignment.STARTThe position property specifies the number of pixels that the start of the tabbed text is from the start of the text line.TabAlignment.CENTERThe position property specifies the number of pixels that the center of the tabbed text is from the start of the text line.TabAlignment.ENDThe position property specifies the number of pixels that the end of the tabbed text is from the start of the text line.TabAlignment.DECIMALThe position property specifies the number of pixels that the alignment token is from the start of the text line.
TabAlignmentTextBlock.createTextLine()
decimalAlignmentToken Specifies the alignment token to use when you set the alignment property to TabAlignment.DECIMAL.String Specifies the alignment token to use when you set the alignment property to TabAlignment.DECIMAL. The value is a String that occurs in the text line.

The default value is "".

TabAlignment.DECIMAL
position The position of the tab stop, in pixels, relative to the start of the text line.NumberIf set to a value less than 0.0. ArgumentErrorArgumentError The position of the tab stop, in pixels, relative to the start of the text line.

The default value is 0.0.

FontLookup The FontLookup class is an enumeration of constant values used with FontDescription.fontLookup.Object The FontLookup class is an enumeration of constant values used with FontDescription.fontLookup. FontDescription.fontLookupDEVICE Used to indicate device font lookup.deviceString Used to indicate device font lookup. The Flash runtime uses the fonts installed on the system that is running application.

Using device fonts results in a smaller movie size, because font data is not included in the file.

Text rendered with device fonts is not always displayed the same across different systems and platforms, because the Flash runtime uses the fonts that are installed on the system.

EMBEDDED_CFF Used to indicate embedded CFF (Compact Font Format) font lookup.embeddedCFFString Used to indicate embedded CFF (Compact Font Format) font lookup. The Flash runtime uses font outlines embedded in the published application.

Text rendered with embedded fonts is always displayed in the chosen font, whether that font is installed on the playback system or not.

One drawback to embedded fonts is that they increase the size of the application.

DigitCase The DigitCase class is an enumeration of constant values used in setting the digitCase property of the ElementFormat class.Object The DigitCase class is an enumeration of constant values used in setting the digitCase property of the ElementFormat class. flash.text.engine.ElementFormat.digitCaseDEFAULT Used to specify default digit case.defaultString Used to specify default digit case. The results are font-dependent; characters use the settings specified by the font designer without any features applied. LINING Used to specify lining digit case.liningString Used to specify lining digit case. OLD_STYLE Used to specify old style digit case.oldStyleString Used to specify old style digit case. TypographicCase The TypographicCase class is an enumeration of constant values for setting the typographicCase property of the ElementFormat class.Object The TypographicCase class is an enumeration of constant values for setting the typographicCase property of the ElementFormat class. ElementFormat.typographicCaseCAPS_AND_SMALL_CAPS Specifies that all lowercase characters use small-caps glyphs on output.capsAndSmallCapsString Specifies that all lowercase characters use small-caps glyphs on output. CAPS Specifies that spacing is adjusted for uppercase characters on output.capsString Specifies that spacing is adjusted for uppercase characters on output. DEFAULT Specifies default typographic case.defaultString Specifies default typographic case. The results are font-dependent; characters use the settings specified by the font designer without any features applied. LOWERCASE Specifies that all characters use lowercase glyphs on output.lowercaseString Specifies that all characters use lowercase glyphs on output. SMALL_CAPS Specifies that uppercase characters use small-caps glyphs on output.smallCapsString Specifies that uppercase characters use small-caps glyphs on output. TITLE Specifies that uppercase characters use title glyphs on output.titleString Specifies that uppercase characters use title glyphs on output. UPPERCASE Specifies that all characters use uppercase glyphs on output.uppercaseString Specifies that all characters use uppercase glyphs on output. TextElement The TextElement class represents a string of formatted text.flash.text.engine:ContentElement The TextElement class represents a string of formatted text. Assign a TextElement object to the content property of a TextBlock object to create a block of text. Assign it to a GroupElement object to combine it with other text and graphic elements as a unit. Use the ElementFormat class to format the text. ContentElementElementFormatTextBlockTextElement Creates a new TextElement instance.textStringnullThe text for the element. The default value is null. elementFormatflash.text.engine:ElementFormatnullThe element format for the text in the element. The default value is null. eventMirrorflash.events:EventDispatchernullThe EventDispatcher object that receives copies of every event dispatched to text lines based on this content element. The default value is null. textRotationStringrotate0The rotation applied the element as a unit. Use TextRotation constants for this property. The default value is TextRotation.ROTATE_0. Creates a new TextElement instance. The following example creates a TextElement object from a string of text, formats it using a font size of 12 and the color red (0xCC0000), and assigns it to the content property of a TextBlock. It calls the createLines() function to break the block of text into lines of 150 pixels each. package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; public class TextElementExample extends Sprite { public function TextElementExample():void { var str:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut " + "enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " + "aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit " + "in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur " + "sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " + "mollit anim id est laborum."; var format:ElementFormat = new ElementFormat(null, 12, 0xCC0000); var textElement:TextElement = new TextElement(str, format); var textBlock:TextBlock = new TextBlock(); textBlock.content = textElement; createLines(textBlock); } private function createLines(textBlock:TextBlock):void { var yPos = 20; var textLine:TextLine = textBlock.createTextLine (null, 150); while (textLine) { addChild(textLine); textLine.x = 15; yPos += textLine.textHeight+2; textLine.y = yPos; textLine = textBlock.createTextLine(textLine, 150); } } } } replaceText Replaces the range of characters that the beginIndex and endIndex parameters specify with the contents of the newText parameter.The beginIndex or endIndex specified is out of range. RangeErrorRangeErrorbeginIndexintThe zero-based index value for the start position of the replacement range. endIndexintThe zero-based index value following the end position of the replacement range. newTextStringThe text to use to replace the specified range of characters. Replaces the range of characters that the beginIndex and endIndex parameters specify with the contents of the newText parameter. The beginIndex and endIndex values refer to the current contents of text.

To delete text, pass null for newText.

To insert text, pass the same value for beginIndex and endIndex. The new text is inserted before the specified index.

To append text, pass text.length for beginIndex and endIndex.

To set all the text, pass 0 for beginIndex and text.length for endIndex.

This example calls replaceText() several times to do the following:
  • insert a string at the beginning of text
  • append a string to the end of text
  • insert a string in the middle of text
  • replace text entirely with new text
package { import flash.display.Sprite; import flash.text.engine.FontDescription; import flash.text.engine.ElementFormat; import flash.text.engine.TextElement; import flash.text.engine.TextBlock; import flash.text.engine.TextLine; public class TextElement_replaceTextExample extends Sprite { public function TextElement_replaceTextExample():void { var str:String = "0123456"; var fontDescription:FontDescription = new FontDescription("Arial"); var format:ElementFormat = new ElementFormat(fontDescription); format.fontSize = 14; var textElement:TextElement = new TextElement(str, format); var textBlock:TextBlock = new TextBlock(); textBlock.content = textElement; textElement.replaceText(0, 0, "abc"); createLine(textBlock, 20); //"abc0123456" textElement.replaceText(10, 10, "abc"); createLine(textBlock, 40); // "abc0123456abc" textElement.replaceText(5, 8, "abc"); createLine(textBlock, 60); // "abc01abc56abc" textElement.replaceText(0, 13, "abc"); createLine(textBlock, 80); // "abc" textElement.replaceText(0, 3, "That's all she wrote!"); createLine(textBlock, 100); // "That's all she wrote" */ } private function createLine(textBlock:TextBlock, y:Number):void { var textLine:TextLine = textBlock.createTextLine(null, 150); textLine.x = 10; textLine.y = y; addChild(textLine); } } }
text Receives the text that is the content of the element.String Receives the text that is the content of the element.

The default value is null.

TextLineValidity The TextLineValidity class is an enumeration of constant values for setting the validity property of the TextLine class.Object The TextLineValidity class is an enumeration of constant values for setting the validity property of the TextLine class. TextBlock.firstInvalidLineTextLine.validityINVALID Specifies that the line is invalid.invalidString Specifies that the line is invalid. POSSIBLY_INVALID Specifies that the text line is possibly invalid.possiblyInvalidString Specifies that the text line is possibly invalid. The Flash runtime uses this validity during rebreaking of a previously broken text block whose content has not changed. You cannot set this value. STATIC Specifies that the line is static, and that the connection between the line and the text block has been severed.staticString Specifies that the line is static, and that the connection between the line and the text block has been severed. VALID Specifies that the text line is valid.validString Specifies that the text line is valid. FontPosture The FontPosture class is an enumeration of constant values used with FontDescription.fontPosture to set text to italic or normal.Object The FontPosture class is an enumeration of constant values used with FontDescription.fontPosture to set text to italic or normal. FontDescription.fontPostureITALIC Used to indicate italic font posture.italicString Used to indicate italic font posture. NORMAL Used to indicate normal font posture.normalString Used to indicate normal font posture. JustificationStyle The JustificationStyle class is an enumeration of constant values for setting the justificationStyle property of the EastAsianJustifier class.Object The JustificationStyle class is an enumeration of constant values for setting the justificationStyle property of the EastAsianJustifier class. These constants specify options for handling kinsoku characters, which are Japanese characters that cannot appear at either the beginning or end of a line. EastAsianJustifier.justificationStylePRIORITIZE_LEAST_ADJUSTMENT Bases justification on either expanding or compressing the line, whichever gives a result closest to the desired width.prioritizeLeastAdjustmentString Bases justification on either expanding or compressing the line, whichever gives a result closest to the desired width. PUSH_IN_KINSOKU Bases justification on compressing kinsoku at the end of the line, or expanding it if no kinsoku occurs or if that space is insufficient.pushInKinsokuString Bases justification on compressing kinsoku at the end of the line, or expanding it if no kinsoku occurs or if that space is insufficient. PUSH_OUT_ONLY Bases justification on expanding the line.pushOutOnlyString Bases justification on expanding the line. EastAsianJustifier The EastAsianJustifier class has properties to control the justification options for text lines whose content is primarily East Asian text.flash.text.engine:TextJustifier The EastAsianJustifier class has properties to control the justification options for text lines whose content is primarily East Asian text.

Use the constructor new EastAsianJustifier() to create an EastAsianJustifier object before setting its properties. Setting the properties of an EastAsianJustifier object after it has been applied to a TextBlock does not invalidate the TextBlock.

This example displays a block of Japanese text vertically, using EastAsianJustifier properties to justify the text. package { import flash.text.engine.TextBlock; import flash.text.engine.TextLine; import flash.text.engine.TextElement; import flash.text.engine.TextBaseline; import flash.text.engine.EastAsianJustifier; import flash.text.engine.LineJustification; import flash.text.engine.TextRotation; import flash.text.engine.FontDescription; import flash.text.engine.ElementFormat; import flash.display.Stage; import flash.display.Sprite; import flash.system.Capabilities; public class EastAsianJustifierExample extends Sprite { public function EastAsianJustifierExample():void { var Japanese_txt:String = String.fromCharCode( 0x5185, 0x95A3, 0x5E9C, 0x304C, 0x300C, 0x653F, 0x5E9C, 0x30A4, 0x30F3, 0x30BF, 0x30FC, 0x30CD, 0x30C3, 0x30C8, 0x30C6, 0x30EC, 0x30D3, 0x300D, 0x306E, 0x52D5, 0x753B, 0x914D, 0x4FE1, 0x5411, 0x3051, 0x306B, 0x30A2, 0x30C9, 0x30D3, 0x30B7, 0x30B9, 0x30C6, 0x30E0, 0x30BA, 0x793E, 0x306E ) + "FMS 2" + String.fromCharCode(0x3092, 0x63A1, 0x7528, 0x3059, 0x308B, 0x3068, 0x767a, 0x8868, 0x3057, 0x307e, 0x3057, 0x305F, 0x3002); var textBlock:TextBlock = new TextBlock(); var font:FontDescription = new FontDescription(); var format:ElementFormat = new ElementFormat(); format.fontSize = 12; format.locale = "ja"; format.color = 0xCC0000; textBlock.baselineZero = TextBaseline.IDEOGRAPHIC_CENTER; textBlock.textJustifier = new EastAsianJustifier("ja", LineJustification.ALL_INCLUDING_LAST); textBlock.lineRotation = TextRotation.ROTATE_90; var linePosition:Number = this.stage.stageWidth - 75; if (Capabilities.os.search("Mac OS") > -1) // set fontName: Kozuka Mincho Pro R font.fontName = String.fromCharCode(0x5C0F, 0x585A, 0x660E, 0x671D) + " Pro R"; else font.fontName = "Kozuka Mincho Pro R"; textBlock.content = new TextElement(Japanese_txt, format); var previousLine:TextLine = null; while (true) { var textLine:TextLine = textBlock.createTextLine(previousLine, 320); if (textLine == null) break; textLine.y = 20; textLine.x = linePosition; linePosition -= 25; addChild(textLine); previousLine = textLine; } } } }
JustificationStyleLineJustificationTextBlock.textJustifierEastAsianJustifier Creates an EastAsianJustifier object.The locale specified is null or too short to represent a valid locale. ArgumentErrorArgumentErrorThe lineJustification specified is not a member of LineJustification. ArgumentErrorArgumentErrorThe justificationStyle specified is not a member of JustificationStyle. ArgumentErrorArgumentErrorlocaleStringjaThe locale to determine the justification rules. The default value is "ja". lineJustificationStringallButLastThe type of line justification for the paragraph. Use LineJustification constants for this property. The default value is LineJustification.ALL_BUT_LAST. justificationStyleStringpushInKinsokuThe justification style for the text in a text block using an East Asian justifier. Use JustificationStyle constants for this property. The default value is JustificationStyle.PUSH_IN_KINSOKU. Creates an EastAsianJustifier object. JustificationStyleLineJustificationclone Constructs a cloned copy of the EastAsianJustifier.A copy of the EastAsianJustifier object. flash.text.engine:TextJustifier Constructs a cloned copy of the EastAsianJustifier. justificationStyle Specifies the justification style for the text in a text block.String Specifies the justification style for the text in a text block.

The default value is JustificationStyle.PUSH_IN_KINSOKU.

Use one of the constants in the JustificationStyle class to set the value for this property. The following table lists the possible values:

String valueDescriptionJustificationStyle.PUSH_IN_KINSOKUSpecifies push in justification.JustificationStyle.PUSH_OUT_ONLYSpecifies push out justification.JustificationStyle.PRIORITIZE_LEAST_ADJUSTMENTSpecifies justification wherein the least adjustment is prioritized.
JustificationStyle
RenderingMode The RenderingMode class provides values for rendering mode in the FontDescription class.Object The RenderingMode class provides values for rendering mode in the FontDescription class. FontDescriptionCFF Sets rendering mode to CFF (Compact Font Format).cffString Sets rendering mode to CFF (Compact Font Format). CFF rendering improves readability of text on a display. This setting is recommended for applications that have a lot of small text. This constant is used for the renderingMode property in the FontDescription class. Use the syntax RenderingMode.CFF. flash.text.engine.FontDescription.renderingModeNORMAL Sets rendering mode to the rendering mode that is used in Flash Player 7 and earlier.normalString Sets rendering mode to the rendering mode that is used in Flash Player 7 and earlier. This setting is recommended for animated text. This constant is used for the renderingMode property in the FontDescription class. Use the syntax RenderingMode.NORMAL. flash.text.engine.FontDescription.renderingModeFontMetrics The FontMetrics class contains measurement and offset information about a font.Object The FontMetrics class contains measurement and offset information about a font. The ElementFormat.getFontMetrics() method returns objects of this class. ElementFormat.getFontMetrics()FontMetrics Creates a FontMetrics object.emBoxflash.geom:RectangleThe emBox of the font in pixels. strikethroughOffsetNumberThe offset for a strikethrough in pixels. strikethroughThicknessNumberThe thickness for a strikethrough in pixels. underlineOffsetNumberThe offset for an underline in pixels. underlineThicknessNumberThe thickness for an underline in pixels. subscriptOffsetNumberThe offset for a subscript in pixels. subscriptScaleNumberThe scale to apply to the point size of a subscript. superscriptOffsetNumberThe offset for a superscript in pixels. superscriptScaleNumberThe scale to apply to the point size of a superscript. Creates a FontMetrics object. The FontMetrics object contains information about the metrics of a font in an element format. The flash.text.engine.ElementFormat.getFontMetrics() method returns objects of this class. ElementFormat.getFontMetrics()emBox The emBox value represents the design space of the font and is used to place Chinese, Korean, or Japanese glyphs relative to the Roman baseline.flash.geom:Rectangle The emBox value represents the design space of the font and is used to place Chinese, Korean, or Japanese glyphs relative to the Roman baseline. Typically a square, sized to the point size of the font. The origin (coordinate 0,0) of the emBox is set to the left edge and Roman baseline of the rect. For example, for a 10-point font, the emBox can be a rect [L,T,R,B] of [0, -8.8, 10, 1.2]. strikethroughOffset The strikethroughOffset value is the suggested vertical offset from the Roman baseline for a strikethrough.Number The strikethroughOffset value is the suggested vertical offset from the Roman baseline for a strikethrough.

Note that depending on the rotation of the line, this value is either added or subtracted from the position of the line to find the position for the strikethrough. In a line with TextRotation.ROTATE_0, strikethrough.y = line.y + strikethroughOffset. In a line with TextRotation.ROTATE_90, strikethrough.x = line.x - strikethroughOffset.

When applying decorations such as strikethroughs to a TextLine, the recommended procedure is to specify an eventMirror on the ContentElement which is to receive the decoration. In response to the Event.ADDED event, the bounds of the TextLineMirrorRegion can be used in conjunction with the strikethroughOffset to place the strikethrough.

ContentElement.eventMirrorTextLineMirrorRegion
strikethroughThickness The strikethroughThickness value is the suggested thickness for a strikethrough.Number The strikethroughThickness value is the suggested thickness for a strikethrough. subscriptOffset The subscriptOffset value is the suggested vertical offset from the Roman baseline for a subscript.Number The subscriptOffset value is the suggested vertical offset from the Roman baseline for a subscript.

The subscriptOffset value is used with ElementFormat.baselineShift to position the subscript.

ElementFormat.baselineShift
subscriptScale The subscriptScale value is the suggested scale factor to apply to the point size for a subscript.Number The subscriptScale value is the suggested scale factor to apply to the point size for a subscript. A scale factor of 1.0 means no scaling. superscriptOffset The superscriptOffset value is the suggested vertical offset from the Roman baseline for a superscript.Number The superscriptOffset value is the suggested vertical offset from the Roman baseline for a superscript.

The superscriptOffset value is used with ElementFormat.baselineShift to position the superscript.

ElementFormat.baselineShift
superscriptScale The superscriptScale value is the suggested scale factor to apply to the point size for a superscript.Number The superscriptScale value is the suggested scale factor to apply to the point size for a superscript. A scale factor of 1.0 means no scaling. underlineOffset The underlineOffset value is the suggested vertical offset from the Roman baseline for an underline.Number The underlineOffset value is the suggested vertical offset from the Roman baseline for an underline.

Note that depending on the rotation of the line, this value is either added or subtracted from the position of the line to find the position for the underline. In a line with TextRotation.ROTATE_0, underline.y = line.y + underlineOffset. In a line with TextRotation.ROTATE_90, underline.x = line.x - underlineOffset.

When applying decorations such as underlines to a TextLine, the recommended procedure is to specify an eventMirror on the ContentElement which is to receive the decoration. In response to the Event.ADDED event, the bounds of the TextLineMirrorRegion can be used in conjunction with the underlineOffset to place the underline.

ContentElement.eventMirrorEventTextLineMirrorRegionTextRotation
underlineThickness The underlineThickness value is the suggested thickness for an underline.Number The underlineThickness value is the suggested thickness for an underline.
ElementFormat The ElementFormat class represents formatting information which can be applied to a ContentElement.Object The ElementFormat class represents formatting information which can be applied to a ContentElement. Use the ElementFormat class to create specific text formatting for the various subclasses of ContentElement. The properties of the ElementFormat class apply to device and embedded fonts.

An ElementFormat object that is applied to a ContentElement in a TextBlock does not invalidate the TextBlock. Once an ElementFormat has been applied to a ContentElement, its locked property is set to true. The properties of a locked ElementFormat object cannot be changed. Instead, use the clone() method to create an unlocked copy of the object, which can be modified and assigned to the ContentElement.

This example creates two ElementFormat objects and sets several of their properties. It then assigns the new ElementFormats to a TextElement object, which has been assigned as the content of a TextBlock. Note that changing the ElementFormat of a TextElement does not affect TextLines that have been previously created by the parent TextBlock.

package { import flash.display.Sprite; import flash.text.engine.*; public class ElementFormatExample extends Sprite { public function ElementFormatExample():void { var fd:FontDescription = new FontDescription(); fd.fontName = "Garamond"; fd.fontWeight = flash.text.engine.FontWeight.BOLD; var ef1:ElementFormat = new ElementFormat(fd); ef1.fontSize = 30; ef1.color = 0xFF0000; ef1.alpha = 100; ef1.kerning = flash.text.engine.Kerning.ON; ef1.trackingRight = 2; ef1.typographicCase = flash.text.engine.TypographicCase.UPPERCASE; ef1.alignmentBaseline = flash.text.engine.TextBaseline.DESCENT; ef1.ligatureLevel = flash.text.engine.LigatureLevel.EXOTIC; var ef2:ElementFormat = new ElementFormat(fd); ef2.fontSize = 30; ef2.color = 0xFF0000; ef2.alpha = 0.3; ef2.kerning = flash.text.engine.Kerning.OFF; ef2.typographicCase = flash.text.engine.TypographicCase.LOWERCASE; ef2.digitCase = flash.text.engine.DigitCase.OLD_STYLE; ef2.textRotation = flash.text.engine.TextRotation.ROTATE_180; var str:String = "This is flash text 0123456789"; var tb:TextBlock = new TextBlock(); var te1:TextElement = new TextElement(str, ef1); tb.content = te1; var line1:TextLine = tb.createTextLine(null, 600); addChild(line1); line1.x = 15; line1.y = 30; tb.content.elementFormat = ef2; var line2:TextLine = tb.createTextLine(null, 600); addChild(line2); line2.x = 15; line2.y = 60; } } }
ContentElement.elementFormatElementFormat Creates an ElementFormat object.The fontSize specified is less than 0. ArgumentErrorArgumentErrorThe textRotation specified is not a member of TextRotation. ArgumentErrorArgumentErrorThe dominantBaseline specified is not a member of TextBaseline. ArgumentErrorArgumentErrorThe alignmentBaseline specified is not a member of TextBaseline. ArgumentErrorArgumentErrorThe kerning specified is not a member of Kerning. ArgumentErrorArgumentErrorThe breakOpportunity specified is not a member of BreakOpportunity. ArgumentErrorArgumentErrorThe digitCase specified is not a member of DigitCase. ArgumentErrorArgumentErrorThe digitWidth specified is not a member of DigitWidth. ArgumentErrorArgumentErrorThe ligatureLevel specified is not a member of LigatureLevel. ArgumentErrorArgumentErrorThe typographicCase specified is not a member of TypographicCase. ArgumentErrorArgumentErrorfontDescriptionflash.text.engine:FontDescriptionnullThe FontDescription object which identifies the font used with this element format. The default value is null. If no font description is provided, a default font description is constructed. fontSizeNumber12.0The size of text in pixels. coloruint0x000000The color of text. A hexadecimal number containing three 8-bit RGB components; for example, 0xFF0000 is red and 0x00FF00 is green. alphaNumber1.0The alpha property applied to all line atoms based on the element format. textRotationStringautothe rotation applied to individual glyphs. Use TextRotation constants for this property. dominantBaselineStringromanThe baseline to which the glyphs in the text snap. Use TextBaseline constants for this property. alignmentBaselineStringuseDominantBaselineThe baseline on the containing line to which the dominant baseline snaps. Use TextBaseline constants for this property. baselineShiftNumber0.0The baseline shift for the text in pixels em. kerningStringonThe kerning used for this text. Use constants defined in the Kerning class. trackingRightNumber0.0The tracking or manual kerning applied to the right of each glyph in pixels. trackingLeftNumber0.0The tracking or manual kerning applied to the left of each glyph in pixels. localeStringenThe locale of the text. breakOpportunityStringautoThe line break opportunity applied to this text. Use BreakOpportunity constants for this property. digitCaseStringdefaultThe digit case used for this text. Use DigitCase constants for this property. digitWidthStringdefaultThe digit width used for this text. Use DigitWidth constants for this property. ligatureLevelStringcommonThe ligature level used for this text. Use LigatureLevel constants for this property. typographicCaseStringdefaultThe typographic case used for this text. Use TypographicCase constants for this property. Creates an ElementFormat object. clone Constructs an unlocked, cloned copy of the ElementFormat.An unlocked copy of the ElementFormat object. flash.text.engine:ElementFormat Constructs an unlocked, cloned copy of the ElementFormat.

This example creates an ElementFormat object and sets a FontSize. A new TextElement is created, using the ElementFormat (and therefore locking it), and the TextElement is used as content for a TextBlock. A line of text is created from the TextBlock.

To modify the ElementFormat object, first check its locked property. If true, use the clone() method to create an unlocked copy of the ElementFormat, change its properties, then re-link the new ElementFormat to the TextBlock. When the lines are re-broken, the new lines will have the new font settings.

package { import flash.display.Sprite; import flash.text.engine.*; public class ElementFormat_cloneExample extends Sprite { private var ef1:ElementFormat; private var ef2:ElementFormat; public function ElementFormat_cloneExample():void { var fd:FontDescription = new FontDescription(); fd.fontLookup = flash.text.engine.FontLookup.DEVICE; fd.fontName = "Palatino"; var ef1:ElementFormat = new ElementFormat(fd); ef1.fontSize=20; var str:String = "This is flash text 0123456789"; var tb:TextBlock = new TextBlock(); var te1:TextElement = new TextElement(str, ef1); tb.content = te1; var line1:TextLine = tb.createTextLine(null, 600); addChild(line1); ef2 = (ef1.locked) ? ef1.clone() : ef1; ef2.fontSize = 32; tb.content.elementFormat=ef2; var line2:TextLine = tb.createTextLine(null, 600); addChild(line2); } } }
getFontMetrics Returns a FontMetrics object with properties which describe the emBox, strikethrough position, strikethrough thickness, underline position, and underline thickness for the font specified by fontDescription and fontSize. A FontMetrics object describing properties of the font specified by fontDescription. flash.text.engine:FontMetrics

Returns a FontMetrics object with properties which describe the emBox, strikethrough position, strikethrough thickness, underline position, and underline thickness for the font specified by fontDescription and fontSize.

This example creates an ElementFormat object with an assigned FontDescription and uses the getFontMetrics method to display metrics for the chosen font at 24 points. package { import flash.display.Sprite; import flash.text.engine.*; public class FontMetricsExample extends Sprite { public function FontMetricsExample():void { var fd:FontDescription = new FontDescription(); fd.fontName = "Garamond"; fd.fontWeight = flash.text.engine.FontWeight.BOLD; var ef1:ElementFormat = new ElementFormat(fd); ef1.fontSize = 24; var fm1:FontMetrics = ef1.getFontMetrics(); trace(fm1.emBox); trace(fm1.strikethroughOffset); trace(fm1.strikethroughThickness); trace(fm1.subscriptScale); trace(fm1.subscriptOffset); trace(fm1.superscriptScale); trace(fm1.superscriptOffset); trace(fm1.underlineOffset); trace(fm1.underlineThickness); } } }
FontDescriptionFontMetrics
alignmentBaseline Specifies the type of baseline in the containing element to which to align the dominant baselines of elements having this format.StringIf set to any value which is not a member of TextBaseline. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Specifies the type of baseline in the containing element to which to align the dominant baselines of elements having this format. Use TextBaseline constants for this property.

The largest vertical element in the line determines the alignment of baselines unless TextBlock.baselineFontDescription and TextBlock.baselineFontSize are set to override that logic.

The default value is TextBaseline.USE_DOMINANT_BASELINE.

To set values for this property, use the following string values:

String valueDescriptionTextBaseline.ROMANThe dominantBaseline aligns with the roman baseline of the line.TextBaseline.ASCENTThe dominantBaseline aligns with the ascent baseline of the line.TextBaseline.DESCENTThe dominantBaseline aligns with the descent baseline of the line.TextBaseline.IDEOGRAPHIC_TOPThe dominantBaseline aligns with the ideographic top baseline of the line.TextBaseline.IDEOGRAPHIC_CENTERThe dominantBaseline aligns with the ideographic center baseline of the line.TextBaseline.IDEOGRAPHIC_BOTTOMThe dominantBaseline aligns with the ideographic bottom baseline of the line.TextBaseline.USE_DOMINANT_BASELINEThe dominantBaseline aligns with the same baseline of the line.

SubclassEffect of setting propertyGraphicElementSets the alignment baseline of the line to which the dominantBaseline of the graphic element aligns.GroupElementHas no effect.TextElementSets the alignment baseline of the line to which the dominantBaseline of the text element aligns. TextBaselineElementFormat.dominantBaselinealpha Specifies the transparency of the line elements affected by this obect.NumberIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Specifies the transparency of the line elements affected by this obect. Valid values range from 0 (fully transparent) to 1 (fully opaque). Display objects with alpha set to 0 are active, even though they are invisible.

The default value is 1.

SubclassEffect of setting propertyGraphicElementApplies the specified alpha to the graphic element. Combines multiplicatively with any alpha set on the graphic DisplayObject itself or on the TextLine.GroupElementHas no effect.TextElementApplies the specified alpha to the text element. Combines multiplicatively with any alpha set on the TextLine.
DisplayObject.alpha
baselineShift Indicates the baseline shift for the element in pixels.NumberIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Indicates the baseline shift for the element in pixels.

The element is shifted away from the dominantBaseline by this amount. The offset is added to the y position of the members of the element, so in non-rotated text, a positive baseline shift moves the element down and a negative baseline shift moves the element up.

The default value is 0.0, indicating no shift.

SubclassEffect of setting propertyGraphicElementShifts the graphic away from the baseline.GroupElementHas no effect.TextElementShifts the text away from the baseline.
breakOpportunity The line break opportunity applied to this text.StringIf set to a value not a member of BreakOpportunity. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The line break opportunity applied to this text. This property determines which characters can be used for breaking when wrapping text is broken into multiple lines. Use BreakOpportunity constants for this property.

The default value is BreakOpportunity.AUTO.

To set values for this property, use the following string values:

String valueDescriptionBreakOpportunity.AUTOLine breaking opportunities are based on standard Unicode character properties, such as breaking between words and on hyphens.BreakOpportunity.ANYAny character in the ContentElement object is treated as a line break opportunity. This value is typically used when Roman text is embedded in Asian text and it is desirable for breaks to happen in the middle of words.BreakOpportunity.NONENo characters in the range are treated as line break opportunities.BreakOpportunity.ALLAll characters in the range are treated as line break opportunities, meaning that a line break will occur after each character. Useful for creating effects like text on a path.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementDetermines the break opportunity between adjacent text elements in the group. If the elementFormat of the group is null, the format of the first of the adjacent elements is used.TextElementDetermines the break opportunity between the characters in the text element. BreakOpportunitycolor Indicates the color of the text.uintIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Indicates the color of the text. An integer containing three 8-bit RGB components; for example, 0xFF0000 is red and 0x00FF00 is green.

The default value is 0x000000, which is black.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementSets the color of the text.
digitCase The digit case used for this text.StringIf set to any value which is not a member of DigitCase. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The digit case used for this text. Digit case affects the style and positioning of groups of numeric characters. Use DigitCase constants for this property.

The default value is DigitCase.DEFAULT.

To set values for this property, use the following string values:

String valueDescriptionDigitCase.DEFAULTApplies default digit case to the text.DigitCase.LININGApplies lining digit case to the text.DigitCase.OLD_STYLEApplies old style digit case to the text.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines the digit case used for the text in the element. DigitCasedigitWidth The digit width used for this text.StringIf set to any value which is not a member of DigitWidth. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The digit width used for this text. Use DigitWidth constants for this property.

The default value is DigitWidth.DEFAULT.

To set values for this property, use the following string values:

String valueDescriptionDigitWidth.DEFAULTApplies default digit width to the text.DigitWidth.PROPORTIONALApplies proportional digit width to the text.DigitWidth.TABULARApplies tabular digit width to the text.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines the digit width used for the text in the element. DigitWidthdominantBaseline Specifies the type of baseline to use as the dominant baseline.StringIf set to any value which is not a member of TextBaseline. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Specifies the type of baseline to use as the dominant baseline. The dominant baseline is aligned with the alignment baseline to determine the vertical position of the element on the line. Use TextBaseline constants for this property.

The content of the element determines the baselines. In the case of a TextElement, the font and the point size determine the baselines. In the case of a GraphicElement, the height of the element determines the baselines.

The default value is TextBaseline.ROMAN.

To set values for this property, use the following string values:

String valueDescriptionTextBaseline.ROMANThe roman baseline of the element aligns with the alignmentBaseline.TextBaseline.ASCENTThe ascent baseline of the element aligns with the alignmentBaseline.TextBaseline.DESCENTThe descent baseline of the element aligns with the alignmentBaseline.TextBaseline.IDEOGRAPHIC_TOPThe ideographic top baseline of the element aligns with the alignmentBaseline.TextBaseline.IDEOGRAPHIC_CENTERThe ideographic center baseline of the element aligns with the alignmentBaseline.TextBaseline.IDEOGRAPHIC_BOTTOMThe ideographic bottom baseline of the element aligns with the alignmentBaseline.

SubclassEffect of setting propertyGraphicElementDetermines which of the baselines of the graphic element aligns with the alignmentBaseline.GroupElementHas no effect.TextElementDetermines which of the baselines of the text element aligns with the alignmentBaseline. TextBaselineElementFormat.alignmentBaselinefontDescription An object whose properties describe a font.flash.text.engine:FontDescriptionIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError An object whose properties describe a font.

The default value is a default-constructed FontDescription object.

When the fontDescription property is set, the FontDescription object provided is locked: its locked property is set to true. A locked FontDescription cannot be modified.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines the font used for the text in the element.
FontDescription
fontSize The size of text in pixels.NumberIf set to a value less than zero. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The size of text in pixels.

The default value is 12.0.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines the size in pixels for the text in the element.
kerning Kerning adjusts the pixels between certain character pairs to improve readability.StringIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Kerning adjusts the pixels between certain character pairs to improve readability. Kerning is supported for all fonts which have kerning tables.

The default value is Kerning.ON.

To set values for this property, use the following constants in the Kerning class:

String valueDescriptionKerning.ONKerning is enabled.Kerning.OFFKerning is disabled.Kerning.AUTOKerning is enabled except where inappropriate in Asian typography. Kerning is applied between two characters if neither is Kanji, Hiragana, or Katakana.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementDetermines whether kerning is applied between adjacent text elements in the group. If the elementFormat of the group is null, the format of the first of the adjacent elements is used.TextElementDetermines whether kerning is applied between the characters in the text element. KerningligatureLevel The ligature level used for this text.StringIf set to any value which is not a member of LigatureLevel. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The ligature level used for this text. A ligature occurs where two or more letter-forms are joined as a single glyph. Ligatures usually replace consecutive characters sharing common components, such as the letter pairs 'fi', 'fl', or 'ae'. They are used with both Latin and non-Latin character sets. Use LigatureLevel constants for this property.

The default value is LigatureLevel.COMMON.

To set values for this property, use the following string values:

String valueDescriptionLigatureLevel.NONENo ligatures are created.LigatureLevel.MINIMUMMinimal ligatures are created.LigatureLevel.COMMONCommon ligatures are created.LigatureLevel.UNCOMMONUncommon ligatures are created.LigatureLevel.EXOTICExotic ligatures are created.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementDetermines the ligature level between adjacent text elements in the group. If the elementFormat of the group is null, the format of the first of the adjacent elements is used.TextElementDetermines the ligature level between the characters in the text element. LigatureLevellocale The locale of the text.StringIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The locale of the text. Controls case transformations and shaping. Standard locale identifiers are used. For example "en", "en_US" and "en-US" are all English, "ja" is Japanese. See iso639-2 code list for a list of locale codes.

The default value is "en".

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines transformations and shaping for the text in the element.
locked Indicates whether the ElementFormat is locked.BooleanIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Indicates whether the ElementFormat is locked. If true the ElementFormat cannot be modified. Call ElementFormat.clone() to get an unlocked copy of the ElementFormat object. textRotation Sets the rotation applied to individual glyphs.StringIf set to any value which is not a member of TextRotation. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Sets the rotation applied to individual glyphs. Use constants defined in the TextRotation class for this property.

The default value is TextRotation.AUTO.

The final rotation of any glyph is the sum of ElementFormat.textRotation, ContentElement.textRotation, and TextBlock.lineRotation.

You typically use this property for Asian text where characters must be rotated to display properly in vertical layout. Use TextRotation.AUTO in combination with TextBlock.lineRotation = TextRotation.ROTATE_90 to accomplish this.

Setting this property on fonts which do not contain vertical layout information can give undesirable results. Fonts that contain a vmtx or VORG table, such as the Japanese font, "MS Mincho", work correctly because the tables supply the data that the layout engine requires for correct layout. Fonts such as Verdana, which do not contain the necessary information, do not.

To set values for this property, use the following string values:

String valueDescriptionTextRotation.ROTATE_0Glyphs are not rotated.TextRotation.ROTATE_90Glyphs are rotated 90 degrees clockwise.TextRotation.ROTATE_180Glyphs are rotated 180 degrees.TextRotation.ROTATE_270Glyphs are rotated 270 degrees clockwise.TextRotation.AUTOSpecifies a 90 degree counter clockwise rotation for full width and wide glyphs only, as determined by the Unicode properties of the glyph. This value is typically used with Asian text to rotate only those glyphs that require rotation. This rotation is applied only in vertical text to return full width and wide characters to a vertical orientation without affecting other characters.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines the rotation of the glyphs in the text element. TextRotationContentElement.textRotationTextBlock.lineRotationtrackingLeft The tracking or manual kerning applied to the left of each glyph in pixels.NumberIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The tracking or manual kerning applied to the left of each glyph in pixels. If kerning is enabled, the trackingLeft value is added to the values in the kerning table for the font. If kerning is disabled, the trackingLeft value is used as a manual kerning value. Supports both positive and negative values.

Typically, the desired tracking value is split between trackingRight and trackingLeft. Otherwise, in mixed directionality text, there is twice the tracking at one bidi boundary and none at the other.

The default value is 0.0.

SubclassEffect of setting propertyGraphicElementDetermines the tracking applied to the left side of the graphic.GroupElementHas no effect.TextElementDetermines the tracking applied to the left side of characters in the text element.

Example:

//positive tracking added to kerning var ef1:ElementFormat = new ElementFormat(); ef1.kerning = flash.text.engine.Kerning.ON; ef1.trackingLeft = 0.5; //negative manual kerning var ef2:ElementFormat = new ElementFormat(); ef2.kerning = flash.text.engine.Kerning.OFF; ef2.trackingLeft = -1.0;
trackingRight The tracking or manual kerning applied to the right of each glyph in pixels.NumberIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The tracking or manual kerning applied to the right of each glyph in pixels. If kerning is enabled, the trackingRight value is added to the values in the kerning table for the font. If kerning is disabled, the trackingRight value is used as a manual kerning value. Supports both positive and negative values.

Typically, the desired tracking value is split between trackingRight and trackingLeft. Otherwise, in mixed directionality text, there is twice the tracking at one bidi boundary and none at the other.

The default value is 0.0.

SubclassEffect of setting propertyGraphicElementDetermines the tracking applied to the right side of the graphic.GroupElementHas no effect.TextElementDetermines the tracking applied to the right side of characters in the text element.

Example:

//positive tracking added to kerning var ef1:ElementFormat = new ElementFormat(); ef1.kerning = flash.text.engine.Kerning.ON; ef1.trackingRight = 0.5; //negative manual kerning var ef2:ElementFormat = new ElementFormat(); ef2.kerning = flash.text.engine.Kerning.OFF; ef2.trackingRight = -1.0;
typographicCase The typographic case used for this text.StringIf set to a value not a member of TypographicCase. ArgumentErrorArgumentErrorIf set after the ElementFormat object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The typographic case used for this text. Use constants defined in the TypographicCase class for this property.

The default value is TypographicCase.DEFAULT.

To set values for this property, use the following string values:

String valueDescriptionTypographicCase.DEFAULTSpecifies that normal case is used for all characters.TypographicCase.TITLESpecifies that uppercase characters use title glyphs on output.TypographicCase.CAPSSpecifies that spacing is adjusted for uppercase characters on output.TypographicCase.SMALL_CAPSSpecifies that uppercase characters use small caps glyphs on output.TypographicCase.UPPERCASESpecifies that all characters use uppercase glyphs on output.TypographicCase.LOWERCASESpecifies that all characters use lowercase glyphs on output.TypographicCase.CAPS_AND_SMALL_CAPSSpecifies that all lowercase characters use small caps glyphs on output.

SubclassEffect of setting propertyGraphicElementHas no effect.GroupElementHas no effect.TextElementDetermines the typographic case used for the text in the element. TypographicCaseTextJustifier The TextJustifier class is an abstract base class for the justifier types that you can apply to a TextBlock, specifically the EastAsianJustifier and SpaceJustifier classes.Object The TextJustifier class is an abstract base class for the justifier types that you can apply to a TextBlock, specifically the EastAsianJustifier and SpaceJustifier classes.

You cannot instantiate the TextJustifier class directly. Invoking new TextJustifier() throws an ArgumentError exception. Setting the properties of an EastAsianJustifier or SpaceJustifier object after you apply it to a TextBlock does not invalidate the TextBlock.

EastAsianJustifierSpaceJustifierTextBlock.textJustifierTextJustifier Calling the new TextJustifier() constructor throws an ArgumentError exception.The locale specified is null or too short to represent a valid locale. ArgumentErrorArgumentErrorThe lineJustification specified is not a member of LineJustification. ArgumentErrorArgumentErrorlocaleStringThe locale to determine the justification rules. lineJustificationStringThe type of line justification for the paragraph. Use LineJustification constants for this property. Calling the new TextJustifier() constructor throws an ArgumentError exception. You can, however, call constructors for the following subclasses of TextJustifier:
  • new SpaceJustifier()
  • new EastAsianJustifier()
EastAsianJustifierLineJustificationSpaceJustifier
clone Constructs a cloned copy of the TextJustifier.A copy of the TextJustifier object. flash.text.engine:TextJustifier Constructs a cloned copy of the TextJustifier.

Subclasses of TextJustifier must override this method.

getJustifierForLocale Constructs a default TextJustifier subclass appropriate to the specified locale.The locale specified is null or too short to represent a valid locale. ArgumentErrorArgumentErrorA reference to a TextJustifier object. flash.text.engine:TextJustifierlocaleStringThe locale to determine the justifier constructed. Constructs a default TextJustifier subclass appropriate to the specified locale.

If the locale is Chinese, Korean, or Japanese, the method constructs a default EastAsianJustifier object. Otherwise the text engine constructs a default SpaceJustifier object.

lineJustification Specifies the line justification for the text in a text block.String Specifies the line justification for the text in a text block.

Use the following constants defined by the LineJustification as valid values for this property:

String valueDescriptionLineJustification.UNJUSTIFIEDGenerates unjustified lines.LineJustification.ALL_BUT_LASTGenerates all lines justified except for the last one.LineJustification.ALL_INCLUDING_LASTGenerates all lines justified.
LineJustification
locale Specifies the locale to determine the justification rules for the text in a text block.StringThe locale specified is null or too short to represent a valid locale. ArgumentErrorArgumentError Specifies the locale to determine the justification rules for the text in a text block. Standard locale identifiers are used. For example "en", "en_US" and "en-US" are all English, "ja" is Japanese.
FontDescription The FontDescription class represents the information necessary to describe a font.Object The FontDescription class represents the information necessary to describe a font.

A FontDescription object is applied to an ElementFormat, which is in turn applied to a ContentElement in a TextBlock. Once a FontDescription has been applied to an ElementFormat, its locked property is set to true. The properties of a locked FontDescription object cannot be changed. Instead, use the clone() method to create an unlocked copy of the object, which can be modified and assigned to the ElementFormat.

Note: FTE (Flash Text Engine) does not support Type 1 fonts or bitmap fonts such as Type 3, ATC, sfnt-wrapped CID, or Naked CID.

This example creates a FontDescription object, assigns a device font to it, sets various font properties, and assigns the new object to an ElementFormat object. Additional font formatting is done within ElementFormat. A new TextElement is created, using the ElementFormat, and the TextElement is used as content for a TextBlock. A line of text is created from the TextBlock.

package { import flash.display.Sprite; import flash.text.engine.*; public class FontDescriptionExample extends Sprite { public function FontDescriptionExample():void { var fd:FontDescription = new FontDescription(); fd.fontLookup = flash.text.engine.FontLookup.DEVICE; fd.fontName = "Palatino"; fd.fontWeight = flash.text.engine.FontWeight.BOLD; fd.fontPosture = flash.text.engine.FontPosture.ITALIC; var ef1:ElementFormat = new ElementFormat(fd); ef1.fontSize = 30; ef1.color = 0xFF0000; var str:String = "This is flash text 0123456789"; var tb:TextBlock = new TextBlock(); var te1:TextElement = new TextElement(str, ef1); tb.content = te1; var line1:TextLine = tb.createTextLine(null, 600); addChild(line1); } } }
ElementFormat.fontDescriptionFontDescription Creates a FontDescription object.The fontWeight specified is not a member of FontWeight. ArgumentErrorArgumentErrorThe fontPosture specified is not a member of FontPosture. ArgumentErrorArgumentErrorThe fontLookup specified is not a member of FontLookup. ArgumentErrorArgumentErrorThe renderingMode specified is not a member of RenderingMode. ArgumentErrorArgumentErrorThe cffHinting specified is not a member of CFFHinting. ArgumentErrorArgumentErrorfontNameString_serifThe name of the font to use, or a comma-separated list of font names. fontWeightStringnormalSpecifies the font weight. fontPostureStringnormalSpecifies the font posture. fontLookupStringdeviceSpecifies how to look up the font. renderingModeStringcffThe rendering mode used for this text. Use RenderingMode constants for this property. cffHintingStringhorizontalStemThe type of CFF (Compact Font Format) hinting used for this text. Use CFFHinting constants for this property. Creates a FontDescription object. clone Constructs an unlocked, cloned copy of the FontDescription.An unlocked copy of the FontDescription object. flash.text.engine:FontDescription Constructs an unlocked, cloned copy of the FontDescription.

This example creates a FontDescription object, assigns a device font to it, sets various font properties, and assigns the new object (and therefore locking it) to an ElementFormat object. A new TextElement is created, using the ElementFormat, and the TextElement is used as content for a TextBlock. A line of text is created from the TextBlock.

To modify the FontDescription object, first check its locked property. If true, use the clone() method to create an unlocked copy of the FontDescription, change its properties, and assign it to a new ElementFormat object. Then re-link the new ElementFormat to the TextBlock. When the lines are re-broken, the new lines will have the new font settings.

package { import flash.display.Sprite; import flash.text.engine.*; public class FontDescription_cloneExample extends Sprite { private var fd:FontDescription; private var fd2:FontDescription; public function FontDescription_cloneExample():void { fd = new FontDescription(); fd.fontLookup = flash.text.engine.FontLookup.DEVICE; fd.fontName = "Palatino"; fd.fontWeight = flash.text.engine.FontWeight.BOLD; fd.fontPosture = flash.text.engine.FontPosture.ITALIC; var ef1:ElementFormat = new ElementFormat(fd); var str:String = "This is flash text 0123456789"; var tb:TextBlock = new TextBlock(); var te1:TextElement = new TextElement(str, ef1); tb.content = te1; var line1:TextLine = tb.createTextLine(null, 600); addChild(line1); fd2 = (fd.locked) ? fd.clone() : fd; fd2.fontWeight = flash.text.engine.FontWeight.NORMAL; var ef2:ElementFormat = new ElementFormat(fd2); tb.content.elementFormat=ef2; var line2:TextLine = tb.createTextLine(null, 600); addChild(line2); } } }
isDeviceFontCompatible Returns true if a usable device font is available with the specified fontName, fontWeight, and fontPosture.The fontWeight specified is not a member of FontWeight. ArgumentErrorArgumentErrorThe fontPosture specified is not a member of FontPosture. ArgumentErrorArgumentErrortrue if a compatible device font is available, otherwise false. BooleanfontNameStringThe name of the device font to check. fontWeightStringSpecifies the font weight. Use FontWeight. fontPostureStringSpecifies the font posture. Use FontPosture. Returns true if a usable device font is available with the specified fontName, fontWeight, and fontPosture.

The flash.text.engine classes can only use OpenType and TrueType device fonts. If a font based on an older font technology is used, the runtime falls back to known good device fonts on a glyph-by-glyph basis to render the text

fontLookupTextBlock.createTextLine()FontPostureFontWeight
isFontCompatible Returns true if an embedded font is available with the specified fontName, fontWeight, and fontPosture where Font.fontType is flash.text.FontType.EMBEDDED_CFF.The fontWeight specified is not a member of FontWeight. ArgumentErrorArgumentErrorThe fontPosture specified is not a member of FontPosture. ArgumentErrorArgumentErrortrue if a compatible embedded font is available, otherwise false. BooleanfontNameStringThe name of the embedded font to check. fontWeightStringSpecifies the font weight. Use FontWeight. fontPostureStringSpecifies the font posture. Use FontPosture. Returns true if an embedded font is available with the specified fontName, fontWeight, and fontPosture where Font.fontType is flash.text.FontType.EMBEDDED_CFF. Starting with Flash Player 10, two kinds of embedded fonts can appear in application content. Normal embedded fonts are only used by TextField. CFF embedded fonts are only used by the flash.text.engine classes. The two types are distinguised by the fontType property of the Font class, as returned by the enumerateFonts() function.

The flash.text.engine classes cannot use a font of type EMBEDDED. If fontLookup is set to FontLookup.EMBEDDED_CFF and the only font available at run time with the specified name, weight, and posture is of type EMBEDDED, the runtime falls back to device fonts on a glyph-by-glyph basis to render the text, as if no embedded font were available with the specified name and style.

If both EMBEDDED and EMBEDDED_CFF fonts are available with the same name, weight, and posture, the EMBEDDED_CFF font is selected and text renders with the EMBEDDED_CFF font.

fontLookupTextBlock.createTextLine()FontType.EMBEDDED_CFFFontPostureFontWeight
cffHinting The type of CFF hinting used for this text.StringIf set to any value which is not a member of CFFHinting. ArgumentErrorArgumentErrorIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The type of CFF hinting used for this text. Use CFFHinting constants for this property. This property applies only if the RenderingMode property of the text is set to RenderingMode.CFF.

The type of CFF (Compact Font Format) hinting used determines whether the Flash runtime forces strong horizontal stems to fit to a sub-pixel grid or not.

Applies only to embedded fonts.

The default value is CFFHinting.HORIZONTAL_STEM.

For the CFFHinting property, you can use the following constants from the CFFHinting class:

String valueDescriptionCFFHinting.NONESpecifies no CFF hinting. Horizontal stems in the glyphs are not forced to the sub-pixel grid. This setting is appropriate for animation or for large font sizes.CFFHinting.HORIZONTAL_STEMSpecifies CFF hinting. Strong horizontal stems are fit to the sub-pixel grid on a screen. To use this setting, the RenderingMode property must be set to RenderingMode.CFF.
CFFHintingFontDescription.renderingModeRenderingMode
fontLookup Specifies how the font should be looked up.StringIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Specifies how the font should be looked up.

The default value is FontLookup.DEVICE.

To set values for this property, use the following string values:

String valueDescriptionFontLookup.DEVICEThe runtime looks up a device font with the specified name on the local system with which to render the text.FontLookup.EMBEDDED_CFFThe runtime looks up an embedded CFF font with the specified name with which to render the text. Only fonts of type flash.text.Font.fontType.EMBEDDED_CFF are considered. If the specified CFF font is not embedded in the application, the runtime attempts to use a fallback device font for each glyph. This method is less efficient than selecting a device font in the first place.
CFFHintingFontLookup
fontName The name of the font to use, or a comma-separated list of font names.StringIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The name of the font to use, or a comma-separated list of font names. The runtime renders the element with the first available font in the list. For example "Arial, Helvetica, _sans" causes the player to search for Arial, then Helvetica, if Arial is not found, then _sans, if neither is found.

Flash runtimes support three generic device font names: _sans (for sans serif fonts), _serif (for serif fonts), and _typewriter (for mono-space fonts). These are mapped to specific device fonts depending on the platform.

The default value is "_serif".

Flash runtimes provide font fallback for glyphs which are not found in the selected font. Whether the font in use is embedded or device, if the glyph is not found in the font, the runtime attempts to render it using another device font likely to contain the glyph.

FontLookup
fontPosture Specifies the font posture.StringIf set to any value which is not a member of FontPosture. ArgumentErrorArgumentErrorIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Specifies the font posture.

The default value is FontPosture.NORMAL.

To set values for this property, use the following constants from the FontPosture class:

ValueDescriptionFontPosture.NORMALNormal font posture.FontPosture.ITALICItalic font posture.
FontPosture
fontWeight Specifies the font weight.StringIf set to any value which is not a member of FontWeight. ArgumentErrorArgumentErrorIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Specifies the font weight.

The default value is FontWeight.NORMAL.

To set values for this property, use the following constants from the FontWeight class:

String valueDescriptionFontWeight.NORMALNormal font weight.FontWeight.BOLDBold font weight.
FontWeight
locked Indicates whether or not the FontDescription is locked.BooleanIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError Indicates whether or not the FontDescription is locked. If true the FontDescription cannot be modified. Call FontDescription.clone() to get an unlocked copy of the FontDescription object. renderingMode The rendering mode used for this text.StringIf set to any value which is not a member of RenderingMode. ArgumentErrorArgumentErrorIf set after the FontDescription object is locked (locked is true). IllegalOperationErrorflash.errors:IllegalOperationError The rendering mode used for this text. Use RenderingMode constants for this property.

Applies only to embedded fonts.

The default value is RenderingMode.CFF.

To set values for this property, use the following constants from the RenderingMode class:

String valueDescriptionRenderingMode.NORMALApplies the regular text rendering, which matches the type of rendering that Flash Player 7 and earlier versions used.RenderingMode.CFFApplies CFF (Compact Font Format) rendering, which makes text more legible. (This feature became available in Flash Player 10.) CFF rendering allows for high-quality rendering of font faces at small sizes.
RenderingMode
GroupElement A GroupElement object groups a collection of TextElement, GraphicElement, or other GroupElement objects that you can assign as a unit to the content property of a TextBlock object.flash.text.engine:ContentElement A GroupElement object groups a collection of TextElement, GraphicElement, or other GroupElement objects that you can assign as a unit to the content property of a TextBlock object. A GroupElement object can also simply share common formatting within another GroupElement object.

When a GroupElement contains another GroupElement, the inner GroupElement retains its own formatting (ElementFormat settings). It does not inherit the formatting of the outer GroupElement.

On a GroupElement, most of the format properties have no impact. For this reason, it is legal to create a text line for a GroupElement object that has a null elementFormat parameter. A few format properties such as kerning and ligature do affect formatting where intersections occur between members of the group. If the group has a null format, the format of the preceding element determines the formatting where intersections occur between members of the group.

This example creates a red box as a GraphicElement object and combines it with two TextElement objects to create a GroupElement object. It assigns the GroupElement object to the content property of a TextBlock, from which it creates three lines. package { import flash.display.Sprite; import flash.display.MovieClip; import flash.text.engine.ContentElement; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.GraphicElement; import flash.text.engine.GroupElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; import flash.text.engine.FontDescription; public class GroupElementExample extends Sprite { public function GroupElementExample():void { var redBox:MovieClip = new MovieClip(); redBox.graphics.beginFill(0xCC0000, 1.0); redBox.graphics.drawRect(0, 0, 20, 20); redBox.graphics.endFill(); var format:ElementFormat = new ElementFormat(); var fontDescription:FontDescription = new FontDescription("Arial"); format.fontSize = 16; format.fontDescription = fontDescription; var str1:String = "This red box is a GraphicElement "; var str2:String = " in the middle of two TextElements, " + " which together make " + "up a GroupElement in a TextBlock that is broken into three lines."; var textElement1:TextElement = new TextElement(str1,format); var graphicElement:GraphicElement = new GraphicElement(redBox,redBox.width,redBox.height, format); var textElement2:TextElement = new TextElement(str2, format); var groupVector:Vector.<ContentElement> = new Vector.<ContentElement>(); groupVector.push(textElement1, graphicElement, textElement2); var groupElement = new GroupElement(groupVector); var textBlock:TextBlock = new TextBlock(); textBlock.content = groupElement; createTextLines(textBlock); } private function createTextLines(textBlock:TextBlock):void { var yPos = 20; var line_length:Number = 450; var textLine:TextLine = textBlock.createTextLine (null, line_length); while (textLine) { addChild(textLine); textLine.x = 15; yPos += textLine.height+8; textLine.y = yPos; textLine = textBlock.createTextLine(textLine, line_length); } } } }
ContentElementGraphicElementTextBlockTextElementGroupElement Creates a new GroupElement instance.The specified element contains null elements. ArgumentErrorArgumentErrorThe specified element contains an element that is not a known subclass of ContentElement. ArgumentErrorArgumentErrorThe specified element contains elements that are specified as the content of a TextBlock. ArgumentErrorArgumentErrorThe specified element contains elements that are already members of a group, or appear more than once in the elements. ArgumentErrorArgumentErrorelementsnullA Vector of ContentElement objects to be contained in the GroupElement. The Vector can be empty. The default value is null. elementFormatflash.text.engine:ElementFormatnullThe element format for the group. The default value is null. This format applies to the intersections between elements in the group; those elements do not inherit the format. eventMirrorflash.events:EventDispatchernullThe EventDispatcher object that receives copies of every event dispatched to text lines created based on this content element. The default value is null. textRotationStringrotate0The rotation applied to the element as a unit. Use TextRotation constants for this property. The default value is TextRotation.ROTATE_0. Creates a new GroupElement instance. ContentElementElementFormatflash.events.EventDispatcherTextLineMirrorRegionTextRotationgetElementAtCharIndex Returns the element containing the character specified by the charIndex parameter.If charIndex is not in the range of 0 - rawText.length. RangeErrorRangeErrorThe element containing the character at charIndex. flash.text.engine:ContentElementcharIndexintThe zero-based index value for the character whose element you want to find. A value of 0 corresponds to the first character in the group, not the first character in the TextBlock. Returns the element containing the character specified by the charIndex parameter. getElementAt Retrieves an element from within the group.If index is out of range. RangeErrorRangeErrorflash.text.engine:ContentElementindexintThe index of the element to retrieve. Retrieves an element from within the group. getElementIndex Returns the index of the element specified by the element parameter.The index of the element specified by element, or -1 if the element is not in the group. intelementflash.text.engine:ContentElementThe element in the group whose index you want to retrieve. Returns the index of the element specified by the element parameter. groupElements Replaces the range of elements that the beginIndex and endIndex parameters specify with a new GroupElement containing those elements.If beginIndex or endIndex is out of range. RangeErrorRangeErrorThe new group. flash.text.engine:GroupElementbeginIndexintThe zero-based index value for the start position of the range to group. endIndexintThe zero-based index value following the end position of the range to group. Replaces the range of elements that the beginIndex and endIndex parameters specify with a new GroupElement containing those elements. As designed, the elements from beginIndex to endIndex-1 are replaced. mergeTextElements Merges the text from the range of elements that the beginIndex and endIndex parameters specify into the element specified by beginIndex without affecting the format of that element.If beginIndex or endIndex is out of range. RangeErrorRangeErrorIf any of the elements in the specified range is not TextElement. ArgumentErrorArgumentErrorThe first text element in the range, now containing all the text in the range. flash.text.engine:TextElementbeginIndexintThe zero-based index value for the start position of the range to merge. endIndexintThe zero-based index value following the end position of the range to merge. Merges the text from the range of elements that the beginIndex and endIndex parameters specify into the element specified by beginIndex without affecting the format of that element. As designed, the text from elements from beginIndex to endIndex-1 are merged. After their text has been merged, elements from beginIndex+1 to endIndex-1 are removed from the group and orphaned, with null group properties. TextElementreplaceElements Replaces the range of elements that the beginIndex and endIndex parameters specify with the contents of the newElements parameter.The beginIndex or endIndex specified is out of range. RangeErrorRangeErrorThe newElements specified contain null elements. ArgumentErrorArgumentErrorThe newElements specified contain this. ArgumentErrorArgumentErrorThe newElements specified contain elements that are not a known subclass of ContentElement . ArgumentErrorArgumentErrorThe newElements specified contain elements that are specified as the content of a TextBlock. ArgumentErrorArgumentErrorThe newElements specified contain elements that are already members of a group or appear more than once in the elements. ArgumentErrorArgumentErrorIf the operation would result in nested rotations within the GroupElement. ArgumentErrorArgumentErrorA Vector containing the elements that were replaced. beginIndexintThe zero-based index value for the start position of the replacement range. endIndexintThe zero-based index value following the end position of the replacement range. newElementsThe elements to use to replace the specified range of elements. Replaces the range of elements that the beginIndex and endIndex parameters specify with the contents of the newElements parameter. The elements from beginIndex to endIndex-1 are replaced.

To delete elements, pass null for newElements. To insert an element, pass the same value for beginIndex and endIndex. The new element is inserted before the specified index. To append an element, pass elementCount for beginIndex and endIndex.

After the operation, the replaced elements are orphaned, with null group properties and returned.

setElements Sets the elements in the group to the contents of the Vector.The value specified contains null elements. ArgumentErrorArgumentErrorThe value specified contains this. ArgumentErrorArgumentErrorThe value specified contains elements that are not a known subclass of ContentElement . ArgumentErrorArgumentErrorThe value specified contains elements that are specified as the content of a TextBlock. ArgumentErrorArgumentErrorThe value specified contains elements that are already members of a group, or appear more than once in the value. ArgumentErrorArgumentErrorIf the operation would result in nested rotations within the GroupElement. ArgumentErrorArgumentErrorvalue Sets the elements in the group to the contents of the Vector. splitTextElement Splits a TextElement into two, creating a new TextElement at the specified position.If elementIndex or charIndex is out of range. RangeErrorRangeErrorIf the element at elementIndex is not a TextElement. ArgumentErrorArgumentErrorThe new text element containing the latter portion of the original text element. flash.text.engine:TextElementelementIndexintThe zero-based index value for the position of the element in the group. splitIndexintThe zero-based index value for the character in the TextElement where the split is to occur. The specified character is the first character in the new TextElement. Splits a TextElement into two, creating a new TextElement at the specified position. TextElementungroupElements Ungroups the elements in a nested GroupElement that groupIndex specifies within an outer GroupElement object.If groupIndex is out of range. RangeErrorRangeErrorIf the element at groupIndex is not a GroupElement. ArgumentErrorArgumentErrorgroupIndexintThe zero-based index value for the position of the group to be split. Ungroups the elements in a nested GroupElement that groupIndex specifies within an outer GroupElement object. After the operation, the ungrouped elements replace the nested GroupElement, which becomes an orphan with a null group property. elementCount The number of elements in the group.int The number of elements in the group.
ContentElement The ContentElement class serves as a base class for the element types that can appear in a GroupElement, namely a GraphicElement, another GroupElement, or a TextElement.Object The ContentElement class serves as a base class for the element types that can appear in a GroupElement, namely a GraphicElement, another GroupElement, or a TextElement.

ContentElement is an abstract base class; therefore, you cannot instantiate ContentElement directly. Invoking new ContentElement() throws an ArgumentError exception.

You can assign a ContentElement element to exactly one GroupElement or to the content property of exactly one text block.

ElementFormatGraphicElementGroupElementTextBlock.contentTextElementTextLineMirrorRegionTextRotationContentElement Calling the new ContentElement() constructor throws an ArgumentError exception.elementFormatflash.text.engine:ElementFormatnullThe element format for the text in the element. The default value is null. eventMirrorflash.events:EventDispatchernullThe EventDispatcher object that receives copies of every event dispatched to valid text lines created based on this content element. The default value is null. textRotationStringrotate0The rotation applied the element as a unit. Use TextRotation constants for this property. The default value is TextRotation.ROTATE_0. Calling the new ContentElement() constructor throws an ArgumentError exception. You can, however, call constructors for the following subclasses of ContentElement:
  • new GraphicElement()
  • new GroupElement()
  • new TextElement()
GRAPHIC_ELEMENT Indicates the presence of a graphic element in the text.0xFDEFuint Indicates the presence of a graphic element in the text. rawTextuserData Provides a way for an application to associate arbitrary data with the element. Provides a way for an application to associate arbitrary data with the element.

The default value is null.

elementFormat The ElementFormat object used for the element.flash.text.engine:ElementFormat The ElementFormat object used for the element.

The default value is null.

When the elementFormat property is set, the ElementFormat object provided is locked: its locked property is set to true. A locked ElementFormat cannot be modified.

ElementFormatTextBlockTextElement
eventMirror The EventDispatcher object that receives copies of every event dispatched to valid text lines based on this content element.flash.events:EventDispatcher The EventDispatcher object that receives copies of every event dispatched to valid text lines based on this content element. The specified object can be used to set up listeners for a text link or other interactive piece of text, as it can be difficult to determine at runtime which parts of lines have resulted from particular content elements. You can also use listeners to apply decorations such as underlines, the metrics of which you cannot determine until after the text is laid out. The default value is null, which means no mirrored events are dispatched.

Event mirrors manifest themselves in text lines as instances of the TextLineMirrorRegion class. Depending on bidirectional processing and line breaking, one or more mirror regions can be produced.

The default value is null.

flash.events.EventDispatcherTextLineMirrorRegion
groupElement The GroupElement object that contains this element, or null if it is not in a group.flash.text.engine:GroupElement The GroupElement object that contains this element, or null if it is not in a group.

The default value is null.

GroupElement
rawText A copy of the text in the element, including any U+FDEF characters.String A copy of the text in the element, including any U+FDEF characters. The Unicode character, U+FDEF, marks the location of a graphic element in the String. textBlockBeginIndex The index in the text block of the first character of this element.int The index in the text block of the first character of this element. This value is not cached; it is calculated whenever this method is called.

The default value is -1.

textBlock The TextBlock to which this element belongs.flash.text.engine:TextBlock The TextBlock to which this element belongs.

The default value is null.

TextBlock
textRotation The rotation to apply to the element as a unit.StringIf set to any value that is not a member of TextRotation. ArgumentErrorArgumentErrorIf set to TextRotation.AUTO. ArgumentErrorArgumentErrorIf the operation would result in nested rotations within a GroupElement. ArgumentErrorArgumentError The rotation to apply to the element as a unit. Use TextRotation constants for this property.

The default value is TextRotation.ROTATE_0.

The final rotation of any glyph is the sum of ElementFormat.textRotation, ContentElement.textRotation, and TextBlock.lineRotation.

ContentElement.textRotation is used to create a short run of text whose rotation differs from the containing line. TCY runs in Japanese text are an example. TCY stands for Tate-Chu-Yoko and refers to a little horizontal run of text (usually a number) in some vertical Japanese text. To create a Paragraph of vertical Japanese text containing a TCY run, do the following:

  1. Set TextBlock.lineRotation=TextRotation.ROTATE_90
  2. Set TextBlock.content to a GroupElement, consisting of three TextElement objects. The first of these elements is the Japanese text before the TCY run, the second is the Latin text of the TCY run, and the third is the Japanese text after the TCY run.
  3. Set the textRotation property of the TCY TextElement to TextRotation.ROTATE_270. The TCY text element rotates as a unit. It starts with a 90 degree rotation inherited from the line. Adding another 270 degrees takes it around to horizontal.

Rotated content elements cannot be nested. In any hierarchy of content elements, no matter how complex, only one content element can have its textRotation property set. The following methods and property setters throw an argument error if nested rotations are detected:

  1. ContentElement.textRotation
  2. GroupElement.setElements
  3. GroupElement.replaceElements

To set values for this property, use the following string values:

String valueDescriptionTextRotation.ROTATE_0Element is not rotated.TextRotation.ROTATE_90Element is rotated 90 degrees clockwise.TextRotation.ROTATE_180Element is rotated 180 degrees.TextRotation.ROTATE_270Element is rotated 270 degrees clockwise.TextRotation.AUTONot supported.
TextRotationElementFormat.textRotationTextBlock.lineRotation
text A copy of the text in the element, not including any U+FDEF characters, which represent graphic elements in the String.String A copy of the text in the element, not including any U+FDEF characters, which represent graphic elements in the String. TextElement.text
TextBlock The TextBlock class is a factory for the creation of TextLine objects, which you can render by placing them on the display list.Object The TextBlock class is a factory for the creation of TextLine objects, which you can render by placing them on the display list.

The TextBlock class is intended to contain a single paragraph because the Unicode bidirectional and line-break algorithms operate on one paragraph at a time. For applications that compose multiple paragraphs of text, use a markup language, or text analysis to divide the text into paragraphs and create one TextBlock per paragraph.

The TextBlock object stores its content in the content property, which is an instance of the ContentElement class. Because you can't create an instance of the ContentElement class, set content to an instance of one of its subclasses: TextElement, GraphicElement, or GroupElement. Use TextElement for purely text content, GraphicElement for an image or graphic content, and GroupElement for content that contains a combination of TextElement, GraphicElement, and other GroupElement objects. See the ContentElement class and its subclasses for details on managing formatted runs of text, embedded sub-runs, and graphic elements.

After you create the TextBlock instance and set the content property, call the createTextLine() method to create lines of text, which are instances of the TextLine class.

This example displays three TextBlock paragraphs of Japanese and English text. The Japanese text is converted to Strings from Unicode character codes. When you click on the button, the example rotates the text from horizontal to vertical or from veritcal to horizontal. package { import fl.controls.Button; import flash.text.engine.TextBlock; import flash.text.engine.TextLine; import flash.text.engine.TextElement; import flash.text.engine.ElementFormat; import flash.text.engine.TextRotation; import flash.text.engine.TextBaseline; import flash.text.engine.LineJustification; import flash.text.engine.FontDescription; import flash.text.engine.EastAsianJustifier; import flash.display.Loader; import flash.display.Sprite; import flash.display.Stage; import flash.events.MouseEvent; import flash.system.Capabilities; public class TextBlockExample extends Sprite { var vertical:Boolean; var container:Sprite; var textBlocks:Vector.<TextBlock>; var loader:Loader = new Loader(); var directionButton:Button = new Button(); public function TextBlockExample():void { addChild(directionButton); directionButton.width = 30; directionButton.move(50, 350); directionButton.addEventListener(MouseEvent.CLICK, clickHandler); createContent(); createLines(); } private function createEmptyBlock():TextBlock { var textBlock:TextBlock = new TextBlock(); textBlock.baselineZero = TextBaseline.IDEOGRAPHIC_CENTER; textBlock.textJustifier = new EastAsianJustifier("ja", LineJustification.ALL_BUT_LAST); textBlock.lineRotation = vertical? TextRotation.ROTATE_90: TextRotation.ROTATE_0; return textBlock; } private function paragraph1(format:ElementFormat):TextBlock { var textBlock:TextBlock = createEmptyBlock(); textBlock.content = new TextElement( String.fromCharCode( 0x5185, 0x95A3, 0x5E9C, 0x304C, 0x300C, 0x653F, 0x5E9C, 0x30A4, 0x30F3, 0x30BF, 0x30FC, 0x30CD, 0x30C3, 0x30C8, 0x30C6, 0x30EC, 0x30D3, 0x300D, 0x306E, 0x52D5, 0x753B, 0x914D, 0x4FE1, 0x5411, 0x3051, 0x306B, 0x30A2, 0x30C9, 0x30D3, 0x30B7, 0x30B9, 0x30C6, 0x30E0, 0x30BA, 0x793E, 0x306E ) + "FMS 2" + String.fromCharCode(0x3092, 0x63A1, 0x7528, 0x3059, 0x308B, 0x3068, 0x767a, 0x8868, 0x3057, 0x307e, 0x3057, 0x305F, 0x3002), format); return textBlock; } private function paragraph2(format:ElementFormat):TextBlock { var textBlock:TextBlock = createEmptyBlock(); textBlock.content = new TextElement( String.fromCharCode( 0x30AF, 0x30ED, 0x30B9, 0x30D7, 0x30E9, 0x30C3, 0x30C8, 0x30D5, 0x30A9, 0x30FC, 0x30E0, 0x4E0A, 0x3067, 0x518D, 0x751F, 0x53EF, 0x80FD, 0x306A ) + "Flash Video" + String.fromCharCode( 0x3092, 0x914D, 0x4FE1, 0x3001, 0x653F, 0x5E9C, 0x6700, 0x65B0, 0x60C5, 0x5831, 0x3092, 0x3088, 0x308A, 0x591A, 0x304F, 0x306E, 0x56FD, 0x6C11, 0x306B, 0x9AD8, 0x54C1, 0x8CEA, 0x306A, 0x753B, 0x50CF, 0x3067, 0x7C21, 0x5358, 0x304B, 0x3064, 0x30EA, 0x30A2, 0x30EB, 0x30BF, 0x30A4, 0x30E0, 0x306B, 0x63D0, 0x4F9B, 0x3059, 0x308B, 0x3053, 0x3068, 0x304C, 0x53EF, 0x80FD, 0x306B, 0x306A, 0x308A, 0x307e, 0x3057, 0x305F, 0x3002), format); return textBlock; } private function paragraph3(format:ElementFormat):TextBlock { var textBlock:TextBlock = createEmptyBlock(); textBlock.content = new TextElement( String.fromCharCode(0x3010) + "2007" + String.fromCharCode(0x5E74) + "2" + String.fromCharCode(0x6708) + "21" + String.fromCharCode(0x65E5, 0x3011), format); return textBlock; } private function createContent():void { var font:FontDescription = new FontDescription(); if (Capabilities.os.search("Mac OS") > -1) font.fontName = String.fromCharCode(0x5C0F, 0x585A, 0x660E, 0x671D) + " Pro R"; // "Kozuka Mincho Pro R" koFont.fontName = "Adobe " + String.fromCharCode(0xBA85, 0xC870) + " Std M"; // "Adobe Myungjo Std M" else font.fontName = "Kozuka Mincho Pro R"; var format:ElementFormat = new ElementFormat(); format.fontDescription = font; format.fontSize = 12; format.locale = "ja"; format.color = 0x000000; if (!vertical) format.textRotation = TextRotation.ROTATE_0; textBlocks = new Vector.<TextBlock>(); textBlocks.push( paragraph1(format), paragraph2(format), paragraph3(format)//, ); } private function createLines():void { if (container != null) { removeChild(container); } container = new Sprite(); container.y = 45; container.x = 40; addChild(container); var linePosition:Number = vertical? this.stage.stageWidth - 120: 12; for (var i:uint = 0; i < textBlocks.length; i++) { var textBlock:TextBlock = textBlocks[i]; var previousLine:TextLine = null; while (true) { var textLine:TextLine = textBlock.createTextLine( previousLine, 300); if (textLine == null) break; if (vertical) { textLine.x = linePosition; linePosition -= 24; directionButton.label = " -- "; } else { textLine.y = linePosition+50; linePosition += 24; directionButton.label = " | "; } container.addChild(textLine); previousLine = textLine; } if (vertical) linePosition -= 16; else linePosition += 16; } } private function clickHandler(event:MouseEvent):void { vertical = !vertical; createContent(); createLines(); } } }
ContentElementGraphicElementGroupElementTextBaselineTextElementTextJustifierTextLineTextRotationTabStopTextBlock Creates a TextBlock object The content specified is not a known subclass of ContentElement. ArgumentErrorArgumentErrorThe content specified is already a member of a group. ArgumentErrorArgumentErrorThe lineRotation specified is not a member of TextRotation. ArgumentErrorArgumentErrorThe baselineZero specified is not a member of TextBaseline. ArgumentErrorArgumentErrorThe bidiLevel specified is less than 0. ArgumentErrorArgumentErrorThe tabStops specified contain null elements. ArgumentErrorArgumentErrorThe tabStops specified are not sorted by increasing position. ArgumentErrorArgumentErrorThe baselineFontSize specified is less than 0. ArgumentErrorArgumentErrorcontentflash.text.engine:ContentElementnullThe contents of the text block. tabStopsnullThe tab stops for the text in the text block. textJustifierflash.text.engine:TextJustifiernullThe TextJustifier object to use during line creation for this block. If no justifier is provided, a default justifier is constructed based on an English locale. lineRotationStringrotate0The rotation applied to the text lines generated from the text block as units. baselineZeroStringromanSpecifies which baseline is at y=0 for all lines in the block. bidiLevelint0The default bidirectional embedding level of the text in the text block. applyNonLinearFontScalingBooleantrueSpecifies that you want to enhance screen appearance at the expense of WYSIWYG print fidelity. baselineFontDescriptionflash.text.engine:FontDescriptionnullSpecifies a font description from which to derive line baselines for all lines in the block. baselineFontSizeNumber12.0Specifies the size to use with the baselineFontDescription. This parameter is ignored if baselineFontDescription is null. Creates a TextBlock object applyNonLinearFontScalingbaselineFontDescriptionbaselineFontSizebaselineZerobidiLevellineRotationtabStopsTextJustifiercreateTextLine Instructs the text block to create a line of text from its content, beginning at the point specified by the previousLine parameter and breaking at the point specified by the width parameter.If the TextLine specified by previousLine is not valid. ArgumentErrorArgumentErrorIf the TextLine specified by previousLine is owned by a different TextBlock. ArgumentErrorArgumentErrorIf width is less than zero, unless fitSomething is true. ArgumentErrorArgumentErrorIf width is greater than TextLine.MAX_LINE_WIDTH. ArgumentErrorArgumentErrorIf one or more elements in the content of the text block has a null ElementFormat. IllegalOperationErrorflash.errors:IllegalOperationErrorA text line, or null if the text block is empty or the width specified is less than the width of the next element. To distinguish between these cases, check the textLineCreationResult property of the text block. flash.text.engine:TextLinepreviousLineflash.text.engine:TextLinenullSpecifies the previously broken line after which breaking is to commence. Can be null when breaking the first line. widthNumber1000000Specifies the desired width of the line in pixels. The actual width may be less. lineOffsetNumber0.0An optional parameter which specifies the difference in pixels between the origin of the line and the origin of the tab stops. This can be used when lines are not aligned, but it is desirable for their tabs to be so. The default value for this parameter is 0.0. fitSomethingBooleanfalseAn optional parameter which instructs Flash Player to fit at least one character into the text line, no matter what width has been specified (even if width is zero or negative, which would otherwise result in an exception being thrown). Instructs the text block to create a line of text from its content, beginning at the point specified by the previousLine parameter and breaking at the point specified by the width parameter. The text line is a TextLine object, which you can add to the display list.

Breaking lines over a range of a text block that has already been broken can change the validity of lines in and beyond the area where breaking takes place. The status of lines can change from VALID to INVALID or POSSIBLY_INVALID. If a newly broken line aligns perfectly with a previously broken line which has a status of POSSIBLY_INVALID, that previously broken line and all following POSSIBLY_INVALID lines change back to a status of VALID. The validity of lines that have been set to values that are not members of TextLineValidity do not change to VALID, but could change to INVALID. Check the firstInvalidLine property after any change to the text block to see where to begin or continue rebreaking text lines.

You can create artificial word breaks by including the Unicode Zero Width Space (ZWSP) character in the text. This can be useful for languages such as Thai, which require a dictionary for correct line breaking. The Flash runtime does not include such a dictionary.

In order to reduce memory overhead, when all the desired lines have been created, unless it is expected that the lines will need to be repeatedly rebroken due to, for example, the resizing of the container, the user should call the releaseLineCreationData() method allowing the text block to dispose of the temporary data associated with line breaking.

This example calls the createTextLine() method to create lines of text in a text block. It accomplishes this by performing the following tasks:
  • Creating a TextElement from a String and giving it a font size of 20
  • Creating a TextBlock and assigning the TextElement to it
  • Calling createTextLine() to create lines 300 pixels wide from the text block
  • Placing each line on Stage (addChild()) and setting its position (x and y)
package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; import flash.text.engine.FontDescription; public class TextBlock_createTextLineExample extends Sprite { public function TextBlock_createTextLineExample():void { var str:String = "I am a TextElement, created from a String and assigned " + "to the content property of a TextBlock. The createTextLine() method " + "then created these lines, 300 pixels wide, for display." ; var fontDescription:FontDescription = new FontDescription("Arial"); var format:ElementFormat = new ElementFormat(fontDescription); format.fontSize = 16; var textElement:TextElement = new TextElement(str, format); var textBlock:TextBlock = new TextBlock(); textBlock.content = textElement; createLines(textBlock); } private function createLines(textBlock:TextBlock):void { var lineWidth:Number = 300; var xPos:Number = 15.0; var yPos:Number = 20.0; var textLine:TextLine = textBlock.createTextLine (null, lineWidth); while (textLine) { textLine.x = xPos; textLine.y = yPos; yPos += textLine.height + 2; addChild (textLine); textLine = textBlock.createTextLine (textLine, lineWidth); } } } }
TextLineTextLine.validityTextLineValidityTextBlock.releaseLineCreationData()
dump Dumps the underlying contents of the TextBlock as an XML string.String Dumps the underlying contents of the TextBlock as an XML string. This can be useful in automated testing, and includes text, formatting, and layout information.

The following describes the output:

	 >block<
	 	[0-N LINE]
	 >/block<
	 

For a description of the output for each line, see the TextLine.dump() method.

Note: The content and format of the output may change in the future. Adobe does not guarantee backward compatibility of this method.

TextLine.dump()
findNextAtomBoundary Finds the index of the next atom boundary from the specified character index, not including the character at the specified index.The index specified is out of range. RangeErrorRangeErrorThe TextLine to which the indexed character belongs is not valid. IllegalOperationErrorflash.errors:IllegalOperationErrorThe index of the next atom boundary from the specified character index. intafterCharIndexintSpecifies the index of the character from which to search for the next atom boundary. Finds the index of the next atom boundary from the specified character index, not including the character at the specified index. The characters between atom boundaries combine to form one atom in a TextLine, such as an 'e' and a combining acute accent. TextLine.atomCountfindNextWordBoundary Finds the index of the next word boundary from the specified character index, not including the character at the specified index.The index specified is out of range. RangeErrorRangeErrorThe TextLine to which the indexed character belongs is not valid. IllegalOperationErrorflash.errors:IllegalOperationErrorThe index of the next word boundary from the specified character index. intafterCharIndexintSpecifies the index of the character from which to search for the next word boundary. Finds the index of the next word boundary from the specified character index, not including the character at the specified index. Word boundaries are determined based on the Unicode properties of the characters. findPreviousAtomBoundary Finds the index of the previous atom boundary to the specified character index, not including the character at the specified index.The index specified is out of range. RangeErrorRangeErrorThe TextLine to which the indexed character belongs is not valid. IllegalOperationErrorflash.errors:IllegalOperationErrorThe index of the previous atom boundary to the specified character index. intbeforeCharIndexintSpecifies the index of the character from which to search for the previous atom boundary. Finds the index of the previous atom boundary to the specified character index, not including the character at the specified index. The characters between atom boundaries combine to form one atom in a TextLine, such as an 'e' and a combining acute accent. TextLine.atomCountfindPreviousWordBoundary Finds the index of the previous word boundary to the specified character index, not including the character at the specified index.The index specified is out of range. RangeErrorRangeErrorThe TextLine to which the indexed character belongs is not valid. IllegalOperationErrorflash.errors:IllegalOperationErrorThe index of the previous word boundary to the specified character index. intbeforeCharIndexintSpecifies the index of the character from which to search for the previous word boundary. Finds the index of the previous word boundary to the specified character index, not including the character at the specified index. Word boundaries are determined based on the Unicode properties of the characters. getTextLineAtCharIndex Returns the TextLine containing the character specified by the charIndex parameter.The character index specified is out of range. RangeErrorRangeErrorThe TextLine containing the character at charIndex. flash.text.engine:TextLinecharIndexintThe zero-based index value of the character (for example, the first character is 0, the second character is 1, and so on). Returns the TextLine containing the character specified by the charIndex parameter. recreateTextLine Instructs the text block to re-use an existing text line to create a line of text from its content, beginning at the point specified by the previousLine parameter and breaking at the point specified by the width parameter.If textLine is null. ArgumentErrorArgumentErrorIf the TextLine specified by previousLine is not valid. ArgumentErrorArgumentErrorIf the TextLine specified by previousLine is owned by a different TextBlock. ArgumentErrorArgumentErrorIf the TextLine specified by previousLine is also specified by textLine. ArgumentErrorArgumentErrorIf width is less than zero, unless fitSomething is true. ArgumentErrorArgumentErrorIf width is greater than TextLine.MAX_LINE_WIDTH. ArgumentErrorArgumentErrorIf one or more elements in the content of the text block has a null ElementFormat. IllegalOperationErrorflash.errors:IllegalOperationErrorA text line, or null if the text block is empty or the width specified is less than the width of the next element. To distinguish between these cases, check the textLineCreationResult property of the text block. flash.text.engine:TextLinetextLineflash.text.engine:TextLineSpecifies a previously created TextLine to be re-used. previousLineflash.text.engine:TextLinenullSpecifies the previously broken line after which breaking is to commence. Can be null when breaking the first line. widthNumber1000000Specifies the desired width of the line in pixels. The actual width may be less. lineOffsetNumber0.0An optional parameter which specifies the difference in pixels between the origin of the line and the origin of the tab stops. This can be used when lines are not aligned, but it is desirable for their tabs to be so. The default value for this parameter is 0.0. fitSomethingBooleanfalseAn optional parameter which instructs Flash Player to fit at least one character into the text line, no matter what width has been specified (even if width is zero or negative, which would otherwise result in an exception being thrown). Instructs the text block to re-use an existing text line to create a line of text from its content, beginning at the point specified by the previousLine parameter and breaking at the point specified by the width parameter. The text line is a TextLine object, which you can add to the display list. By re-using an existing text line, performance is enhanced due to reduced object creation.

The textLine being recreated is released from whatever text block it is in, if any. In addition, all properties, including inherited properties from DisplayObjectContainer, InteractiveObject, and DisplayObject are reset to their default values. Finally, all children of the line are removed including graphic elements and other decorations, and all event listeners on the line are removed. To improve performance, the only exception to this complete reset is that the line itself is not removed from its parent.

Breaking lines over a range of a text block that has already been broken can change the validity of lines in and beyond the area where breaking takes place. The status of lines can change from VALID to INVALID or POSSIBLY_INVALID. If a newly broken line aligns perfectly with a previously broken line which has a status of POSSIBLY_INVALID, that previously broken line and all following POSSIBLY_INVALID lines change back to a status of VALID. The validity of lines that have been set to values that are not members of TextLineValidity do not change to VALID, but could change to INVALID. Check the firstInvalidLine property after any change to the text block to see where to begin or continue rebreaking text lines.

You can create artificial word breaks by including the Unicode Zero Width Space (ZWSP) character in the text. This can be useful for languages such as Thai, which require a dictionary for correct line breaking. The Flash runtime does not include such a dictionary.

In order to reduce memory overhead, when all the desired lines have been created, unless it is expected that the lines will need to be repeatedly rebroken due to, for example, the resizing of the container, the user should call the releaseLineCreationData() method allowing the text block to dispose of the temporary data associated with line breaking.

This example re-uses the TextLine object textLine: var elementFormat:ElementFormat = new ElementFormat(); elementFormat.fontDescription = new FontDescription("Arial"); elementFormat.fontSize = 48; var textElement:TextElement = new TextElement("Text you'll never see", elementFormat) var textBlock:TextBlock = new TextBlock(textElement); var textLine:TextLine = textBlock.createTextLine(); textLine.x = 50; textLine.y = 50; addChild(textLine); // Reuse the element format to preserve the text formatting var elementTwo:TextElement = new TextElement("Text you see", elementFormat); textBlock.content = elementTwo; textBlock.recreateTextLine(textLine); // Set the position (and any other display object properties like alpha, children, etc.) // otherwise, they're all set to default properties. textLine.x = 50; textLine.y = 50;
TextBaselineTextLineTextLine.validityTextLineValidityTextBlock.releaseLineCreationData()
releaseLineCreationData Instructs the text block to release all the temporary data associated with the creation of text lines. Instructs the text block to release all the temporary data associated with the creation of text lines. To minimize an application's memory foot print, you should call the releaseLineCreationData() method when you are done creating text lines from a text block. However, to maximize performance for rebreaking the lines (for example when the container is resized) the releaseLineCreationData() method should not be called. It is up to the application to balance memory vs. performance.

The recommended process for text that is not expected to change is: initialize a text block, call the createTextLine() method as often as necessary to create the desired output, and then call the releaseLineCreationData() method.

TextBlock.createTextLine()
releaseLines Removes a range of text lines from the list of lines maintained by the TextBlock.If the TextLine specified by firstLine or lastLine is not in the list of text lines maintained by the text block. ArgumentErrorArgumentErrorfirstLineflash.text.engine:TextLineSpecifies the first line to release. lastLineflash.text.engine:TextLineSpecifies the last line to release. Removes a range of text lines from the list of lines maintained by the TextBlock. This allows the lines to be garbage-collected if no other references exist.

Sets the textBlock, nextLine, and previousLine members of the removed lines to null. Sets the validity of the removed lines and of all lines which follow the removed lines in the TextBlock to TextLineValidity.INVALID.

TextLine
userData Provides a way for the application to associate arbitrary data with the text block. Provides a way for the application to associate arbitrary data with the text block. The data could be information that refers to the content, such as a revision date or the name of the author, or it could be cached data that you use during processing. applyNonLinearFontScaling Specifies that you want to enhance screen appearance at the expense of what-you-see-is-what-you-get (WYSIWYG) print fidelity.Boolean Specifies that you want to enhance screen appearance at the expense of what-you-see-is-what-you-get (WYSIWYG) print fidelity. For platforms and fonts that do not support sub pixel glyph positioning during device font rendering, but do support non-linear scaling, setting this property to true enables the use of those metrics at some cost to WYSIWYG print fidelity, particularly for small point sizes. Non linear font scaling works by selectivly scaling the width of individual glyphs to conceal unsightly gaps caused by pixel snapping.

On platforms which do support sub-pixel glyph positioning, this flag is ignored.

This flag has no effect on embedded font rendering

The default value is true.

baselineFontDescription The font used to determine the baselines for all the lines created from the block, independent of their content.flash.text.engine:FontDescription The font used to determine the baselines for all the lines created from the block, independent of their content. Baselines depend on font and font size.

The default value is null. When the baseline font is null, the baseline font size is ignored and the baseline for any given line is based on the font and size of the largest text in the line. When you specify both baselineFontDescription and baselineFontSize, they determine the baselines for all the lines in the text block, independent of their content. This combination is most often useful in Asian typography.

baselineFontSizeFontDescription
baselineFontSize The font size used to calculate the baselines for the lines created from the block.NumberThe baselineFontSize specified is less than 0. ArgumentErrorArgumentError The font size used to calculate the baselines for the lines created from the block. Baselines depend on font and font size.

The default value is 12. When the baseline font is null, the baseline font size is ignored and the baseline for any given line is based on the font and size of the largest text in the line.

baselineFontDescriptionFontDescription
baselineZero Specifies which baseline is at y=0 for lines created from this block.StringIf set to any value which is not a member of TextBaseline. ArgumentErrorArgumentError Specifies which baseline is at y=0 for lines created from this block. Valid values for this property are found in the members of the TextBaseline class.

The default value is TextBaseline.ROMAN.

To set values for this property, use the following string values:

String valueDescriptionTextBaseline.ROMANThe roman baseline of the lines is at y=0.TextBaseline.ASCENTThe ascent baseline of the lines is at y=0.TextBaseline.DESCENTThe descent baseline of the lines is at y=0.TextBaseline.IDEOGRAPHIC_TOPThe ideographic top baseline of the lines is at y=0.TextBaseline.IDEOGRAPHIC_CENTERThe ideographic center baseline of the lines is at y=0.TextBaseline.IDEOGRAPHIC_BOTTOMThe ideographic bottom baseline of the lines is at y=0.
TextBaseline
bidiLevel Specifies the default bidirectional embedding level of the text in the text block.intIf set to a value which is less than 0. ArgumentErrorArgumentError Specifies the default bidirectional embedding level of the text in the text block. An even value means left-to-right and an odd value means right-to-left. You can increment bidiLevel to indicate the number of levels by which particular text is embedded with respect to left-to-right and right-to-left.

The default value is 0.

Modifying bidiLevel changes the validity of all previously broken lines to TextLineValidity.INVALID. After changing bidiLevel, the firstInvalidLine property equals the firstLine property, and you must rebreak all the lines in the TextBlock.

This example shows the same text string (logical order: a, b, c, alef, bet, gimel) rendered first with bidiLevel even and second with bidiLevel odd. package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; import flash.text.engine.FontDescription; public class TextBlock_bidiLevelExample extends Sprite { public function TextBlock_bidiLevelExample():void { var fontSize:Number = 36; var format:ElementFormat = new ElementFormat(); format.fontDescription = new FontDescription("Adobe Hebrew"); format.fontSize = fontSize; var y:Number = 0; var leading:Number = fontSize * 0.2; var text:String = "abc" + String.fromCharCode(0x05D0, 0x05D1, 0x05D2); var textBlock:TextBlock = new TextBlock(); textBlock.content = new TextElement(text, format); // bidiLevel even textBlock.bidiLevel = 0; var textLine = textBlock.createTextLine(null, 400); y += leading + textLine.ascent; textLine.y = y; y += textLine.descent; addChild(textLine); // bidiLevel odd textBlock.content = new TextElement(text, format); textBlock.bidiLevel = 1; textLine = textBlock.createTextLine(null, 400); y += leading + textLine.ascent; textLine.y = y; addChild(textLine); } } }
createTextLine()
content Holds the contents of the text block.flash.text.engine:ContentElementIf set to a value which is not a known subclass of ContentElement. ArgumentErrorArgumentErrorThe value specified is already a member of a group. ArgumentErrorArgumentError Holds the contents of the text block. Because ContentElement is a base class, assign content an instance of a ContentElement subclass: TextElement, GraphicElement, or GroupElement. A TextElement object contains a String, a GraphicElement object contains a DisplayObject, and a GroupElement contains a Vector object that contains one or more TextElement, GraphicElement, or other GroupElement objects. Use a TextElement for a paragraph of homogenous text, a GraphicElement for a graphic, and a GroupElement for a combination of text and graphic elements or multiples instances of these elements, as well as other GroupElement objects.

The default value is null.

Modifying the content property changes the validity of all previously created lines to TextLineValidity.INVALID. After changing content, the firstInvalidLine property equals the firstLine property and you must rebreak all lines in the TextBlock.

ContentElementGraphicElementGroupElementTextElementcreateTextLine()
firstInvalidLine Identifies the first line in the text block in which TextLine.validity is not equal to TextLineValidity.VALID.flash.text.engine:TextLine Identifies the first line in the text block in which TextLine.validity is not equal to TextLineValidity.VALID.

The default value is null.

TextLine.validityTextLineValidity
firstLine The first TextLine in the TextBlock, if any.flash.text.engine:TextLine The first TextLine in the TextBlock, if any.

The default value is null.

TextLine
lastLine The last TextLine in the TextBlock, if any.flash.text.engine:TextLine The last TextLine in the TextBlock, if any.

The default value is null.

TextLine
lineRotation Rotates the text lines in the text block as a unit.StringIf set to any value which is not a member of TextRotation. ArgumentErrorArgumentErrorIf set to TextRotation.AUTO. ArgumentErrorArgumentError Rotates the text lines in the text block as a unit. Call the createTextLine() method after setting lineRotation for it to take effect. The default value is TextRotation.ROTATE_0.

The final rotation of any glyph depends on the values of ElementFormat.textRotation, ContentElement.textRotation, and TextBlock.lineRotation.

TextBlock.lineRotation is typically used for Asian text. To create a paragraph of vertical Japanese text, do the following:

  1. Set the TextBlock.lineRotation property to TextRotation.ROTATE_90.
  2. Leave the ElementFormat.textRotation property of the content as the default, TextRotation.AUTO.

Use the following constants, which are defined in the TextRotation class, to set the value for this property:

String valueDescriptionTextRotation.ROTATE_0Lines are not rotated.TextRotation.ROTATE_90Lines are rotated 90 degrees clockwise.TextRotation.ROTATE_180Lines are rotated 180 degrees.TextRotation.ROTATE_270Lines are rotated 270 degrees clockwise.TextRotation.AUTONot supported.
This example adds Japanese text to a TextBlock and sets the lineRotation property to TextRotation.ROTATE_90 to display the line vertically. package { import flash.display.Sprite; import flash.text.engine.FontDescription; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.TextRotation; import flash.text.engine.ElementFormat; public class TextBlock_lineRotationExample extends Sprite { public function TextBlock_lineRotationExample():void { var Japanese:String = String.fromCharCode( 0x5185, 0x95A3, 0x5E9C, 0x304C, 0x300C, 0x653F, 0x5E9C, 0x30A4, 0x30F3, 0x30BF, 0x30FC, 0x30CD, 0x30C3, 0x30C8, 0x30C6, 0x30EC, 0x30D3, 0x300D, 0x306E, 0x52D5, 0x753B, 0x914D, 0x4FE1, 0x5411, 0x3051, 0x306B, 0x30A2, 0x30C9, 0x30D3, 0x30B7, 0x30B9, 0x30C6, 0x30E0, 0x30BA, 0x793E, 0x306E ) + "FMS 2" + String.fromCharCode(0x3092, 0x63A1, 0x7528, 0x3059, 0x308B, 0x3068, 0x767a, 0x8868, 0x3057, 0x307e, 0x3057, 0x305F, 0x3002); var fontDescription:FontDescription = new FontDescription("MS Mincho"); var format:ElementFormat = new ElementFormat(); format.fontSize = 15; format.fontDescription = fontDescription; var textElement:TextElement = new TextElement(Japanese, format); var textBlock:TextBlock = new TextBlock(); textBlock.content = textElement; textBlock.lineRotation = TextRotation.ROTATE_90; var linePosition:Number = this.stage.stageWidth - 120; var previousLine:TextLine = null; while (true) { var textLine:TextLine = textBlock.createTextLine( previousLine, 300); if (textLine == null) break; textLine.y = 30; textLine.x = linePosition; linePosition -= 24; addChild(textLine); previousLine = textLine; } } } }
ContentElement.textRotationElementFormat.textRotationTextLineTextRotation
tabStops Specifies the tab stops for the text in the text block, in the form of a Vector of TabStop objects.The tabStops specified contain null elements. ArgumentErrorArgumentErrorThe tabStops specified are not sorted by increasing position. ArgumentErrorArgumentError Specifies the tab stops for the text in the text block, in the form of a Vector of TabStop objects.

The default value is null, which means no tab stops are specified. When no tab stops are specified (or the insertion point is beyond the last specified tab stop) the runtime creates half-inch tabs by default.

When the tabStops property is set, the TextBlock makes a copy of the Vector for internal use. Modifying the original Vector or its contents does not affect the TextBlock. When the tabStops property is queried, a copy of the internal Vector is returned. Again, modifying this returned vector or its contents does not affect the TextBlock.

TabStop
textJustifier Specifies the TextJustifier to use during line creation.flash.text.engine:TextJustifierIf set to a value which is not a known subclass of TextJustifier. ArgumentErrorArgumentError Specifies the TextJustifier to use during line creation.

The default value is a constructed default TextJustifier object.

When the textJustifier property is set, the TextBlock makes a copy of the object for internal use. Modifying the original object does not affect the TextBlock. When the textJustifier property is queried, a copy of the internal object is returned. Again, modifying this returned object does not affect the TextBlock.

EastAsianJustifierSpaceJustifierTextJustifier
textLineCreationResult Indicates the result of a createTextLine() operation.String Indicates the result of a createTextLine() operation. Changing the content of the block invalidates previously broken lines and resets this property to null.

The default value is null.

Values for this property are found in TextLineCreationResult

String valueDescriptionTextLineCreationResult.SUCCESSThe line was successfully broken.TextLineCreationResult.COMPLETEEither the new line created aligned perfectly with following lines which have transitioned from POSSIBLY_INVALID to VALID, or no line was created because all text in the block had already been broken.TextLineCreationResult.INSUFFICIENT_WIDTHNo line was created because no text could fit in the specified width.
TextLineCreationResult
TextLineCreationResult The TextLineCreationResult class is an enumeration of constant values used with TextBlock.textLineCreationResult.Object The TextLineCreationResult class is an enumeration of constant values used with TextBlock.textLineCreationResult. TextBlock.createTextLine()TextBlock.textLineCreationResultCOMPLETE Indicates no line was created because all text in the block had already been broken.completeString Indicates no line was created because all text in the block had already been broken. EMERGENCY Indicates the line was created with an emergency break because no break opportunity was available in the specified width.emergencyString Indicates the line was created with an emergency break because no break opportunity was available in the specified width. INSUFFICIENT_WIDTH Indicates no line was created because no text could fit in the specified width and fitSomething was not specified in the call to createTextLine().insufficientWidthString Indicates no line was created because no text could fit in the specified width and fitSomething was not specified in the call to createTextLine(). SUCCESS Indicates the line was successfully broken.successString Indicates the line was successfully broken. LigatureLevel The LigatureLevel class is an enumeration of constant values used in setting the ligatureLevel property of the ElementFormat class.Object The LigatureLevel class is an enumeration of constant values used in setting the ligatureLevel property of the ElementFormat class. A ligature occurs where two or more letter-forms are joined as a single glyph. Ligatures usually replace consecutive characters sharing common components, such as the letter pairs 'fi', 'fl', or 'ae'. They are used with both Latin and Non-Latin character sets.

Note: When working with Arabic or Syriac fonts, ligatureLevel must be set to MINIMUM or above.

ElementFormat.ligatureLevelCOMMON Used to specify common ligatures.commonString Used to specify common ligatures. EXOTIC Used to specify exotic ligatures.exoticString Used to specify exotic ligatures. MINIMUM Used to specify minimum ligatures.minimumString Used to specify minimum ligatures. NONE Used to specify no ligatures.noneString Used to specify no ligatures. UNCOMMON Used to specify uncommon ligatures.uncommonString Used to specify uncommon ligatures.
TextRotation The TextRotation class is an enumeration of constant values used with the following properties: ElementFormat.textRotation, ContentElement.textRotation, TextBlock.lineRotation, and TextLine.getAtomTextRotation().Object The TextRotation class is an enumeration of constant values used with the following properties: ElementFormat.textRotation, ContentElement.textRotation, TextBlock.lineRotation, and TextLine.getAtomTextRotation().

The final rotation of any glyph is the sum of TextBlock.lineRotation, ElementFormat.textRotation, and ContentElement.textRotation

ElementFormat.textRotationContentElement.textRotationTextBlock.lineRotationTextLine.getAtomTextRotation()AUTO Specifies a 90 degree counter clockwise rotation for full width and wide glyphs only, as determined by the Unicode properties of the glyph.autoString Specifies a 90 degree counter clockwise rotation for full width and wide glyphs only, as determined by the Unicode properties of the glyph. This value is typically used with Asian text to rotate only those glyphs that require rotation. This rotation is applied only in vertical text to return full width and wide characters to a vertical orientation without affecting other characters. ROTATE_0 Specifies no rotation.rotate0String Specifies no rotation. ROTATE_180 Specifies a 180 degree rotation.rotate180String Specifies a 180 degree rotation. ROTATE_270 Specifies a 270 degree clockwise rotation.rotate270String Specifies a 270 degree clockwise rotation. ROTATE_90 Specifies a 90 degree clockwise rotation.rotate90String Specifies a 90 degree clockwise rotation.
TabAlignment The TabAlignment class is an enumeration of constant values that you can use to set the tabAlignment property of the TabStop class.Object The TabAlignment class is an enumeration of constant values that you can use to set the tabAlignment property of the TabStop class. TabStop.alignmentTextBlock.tabStopsCENTER Positions the center of the tabbed text at the tab stop.centerString Positions the center of the tabbed text at the tab stop. DECIMAL Positions the alignment token of the tabbed text at the tab stop.decimalString Positions the alignment token of the tabbed text at the tab stop. TabStop.decimalAlignmentTokenEND Positions the end of the tabbed text at the tab stop.endString Positions the end of the tabbed text at the tab stop. START Positions the start of the tabbed text at the tab stop.startString Positions the start of the tabbed text at the tab stop. GraphicElement The GraphicElement class represents a graphic element in a TextBlock or GroupElement object.flash.text.engine:ContentElement The GraphicElement class represents a graphic element in a TextBlock or GroupElement object. Assign a GraphicElement object to the content property of a TextBlock object to display a graphic or an image with TextBlock.createTextLine(). Assign it to a GroupElement object to combine it with other graphic and text elements. The following example creates a TextBlock with a GraphicElement (a red box) and displays it, adding a second TextBlock beneath it that contains a caption. package { import flash.display.Sprite; import flash.display.MovieClip; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.GraphicElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; import flash.text.engine.FontDescription; public class GraphicElementExample extends Sprite { public function GraphicElementExample():void { var format:ElementFormat = new ElementFormat(); format.fontSize = 14; var redBox:MovieClip = new MovieClip(); redBox.graphics.beginFill(0xCC0000, 1.0); redBox.graphics.drawRect(0,0, 200, 200); redBox.graphics.endFill(); var graphicElement:GraphicElement = new GraphicElement(redBox,redBox.width,redBox.height, format); var textBlock:TextBlock = new TextBlock(); textBlock.content = graphicElement; var textLine1:TextLine = textBlock.createTextLine(null,redBox.width); addChild(textLine1); textLine1.x = 15 textLine1.y = 215 var str:String = "Your picture here ..."; var textElement:TextElement = new TextElement(str, format); textBlock = new TextBlock(); textBlock.content = textElement; var textLine2 = textBlock.createTextLine(null, 300); addChild(textLine2); textLine2.x = textLine1.x; textLine2.y += textLine1.y + format.fontSize; } } } ContentElementGroupElementTextBlockGraphicElement Creates a new GraphicElement instance.graphicflash.display:DisplayObjectnullThe DisplayObject to populate the GraphicElement. The default value is null. elementWidthNumber15.0The width of the area reserved for the element in pixels. The default value is 15. elementHeightNumber15.0The height of the area reserved for the element in pixels. The default value is 15. elementFormatflash.text.engine:ElementFormatnullThe element format for the element. The default value is null. eventMirrorflash.events:EventDispatchernullThe EventDispatcher object that receives copies of every event dispatched to text lines created based on this content element. The default value is null. textRotationStringrotate0The rotation applied to the element as a unit. Use flash.text.engine.TextRotation constants for this property. The default value is flash.text.engine.TextRotation.ROTATE_0. Creates a new GraphicElement instance.

The registration point of the graphic aligns with the upper-left corner of the region defined by elementHeight, elementWidth and elementFormat.baselineShift. The graphic is not scaled to match the size of the region. If the GraphicElement has an eventMirror, the elementWidth and elementHeight properties, and not the graphic, determine the size and position of the resulting mirror region. If a loader is used, the graphic might not be loaded at the time the text line and the mirror regions are created.

GroupElement
elementHeight The height in pixels to reserve for the graphic in the line.Number The height in pixels to reserve for the graphic in the line. It is the responsibility of the caller to scale the graphic.

The default value is 15.0.

elementWidth The width in pixels to reserve for the graphic in the line.Number The width in pixels to reserve for the graphic in the line. It is the responsibility of the caller to scale the graphic.

The default value is 15.0.

graphic The DisplayObject to be used as a graphic for the GraphicElement.flash.display:DisplayObject The DisplayObject to be used as a graphic for the GraphicElement.

The default value is null.

When the GraphicElement becomes part of a text line, the graphic is added as a child of the line. Setting the graphic removes the old graphic from the line and adds the new one.

FontWeight The FontWeight class is an enumeration of constant values used with FontDescription.fontWeight.Object The FontWeight class is an enumeration of constant values used with FontDescription.fontWeight. flash.text.engine.FontDescription.fontWeightBOLD Used to indicate bold font weight.boldString Used to indicate bold font weight. NORMAL Used to indicate normal font weight.normalString Used to indicate normal font weight. TextBaseline The TextBaseline class is an enumeration of constant values to use in setting the dominantBaseline and alignmentBaseline properties of the ElementFormat class.Object The TextBaseline class is an enumeration of constant values to use in setting the dominantBaseline and alignmentBaseline properties of the ElementFormat class. You can also use it in the baselineZero property of the TextBlock class. Consider this situation:

The line consists of four TextElement objects, containing 'a', 'b', 'cccccccc', and 'X' respectively. The element containing 'X' determines the line baselines because it is the largest element in the line. The roman baseline of the 'X' element is aligned with the roman baseline of the line. The ideographic top of the 'a' element is aligned with the ideographic top of the line. The ideographic bottom of the 'b' element is aligned with the ideographic bottom of the line. The ideographic center of the 'cccccccc' element is aligned with the ideographic center of the line.

ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroASCENT Specifies an ascent baseline.ascentString Specifies an ascent baseline. For a text element, the font and point size of the text determine this value. For a graphic element, the text engine uses the geometric top of the element. ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroDESCENT Specifies a descent baseline.descentString Specifies a descent baseline. For a text element, the font and point size of the text determine this value. For a graphic element, the text element uses the geometric bottom of the element. ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroIDEOGRAPHIC_BOTTOM Specifies an ideographic bottom baseline.ideographicBottomString Specifies an ideographic bottom baseline. For a text element, the font and point size of the text determine this value. For a graphic element, the text engine uses the geometric bottom of the element. ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroIDEOGRAPHIC_CENTER Specifies an ideographic center baseline.ideographicCenterString Specifies an ideographic center baseline. For a text element, the font and point size of the text determine this value. For a graphic element, the text engine uses the geometric center of the element. ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroIDEOGRAPHIC_TOP Specifies an ideographic top baseline.ideographicTopString Specifies an ideographic top baseline. For a text element, the font and point size of the text determine this value. For a graphic element, the text engine uses the geometric top of the element. ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroROMAN Specifies a roman baseline.romanString Specifies a roman baseline. For a text element, the font and point size of the text determine this value. For a graphic element, the text engine uses the geometric bottom of the element. ElementFormat.dominantBaselineElementFormat.alignmentBaselineTextBlock.baselineZeroUSE_DOMINANT_BASELINE Specifies that the alignmentBaseline is the same as the dominantBaseline.useDominantBaselineString Specifies that the alignmentBaseline is the same as the dominantBaseline. Use this value only to set ElementFormat.alignmentBaseline. ElementFormat.alignmentBaseline
BreakOpportunity The BreakOpportunity class is an enumeration of constant values that you can use to set the breakOpportunity property of the ElementFormat class.Object The BreakOpportunity class is an enumeration of constant values that you can use to set the breakOpportunity property of the ElementFormat class. This property determines which characters can be used for breaking when wrapping text is broken into multiple lines. ElementFormat.breakOpportunityALL Treats all characters in the ContentElement object as line break opportunities, meaning that a line break will occur afer each character.allString Treats all characters in the ContentElement object as line break opportunities, meaning that a line break will occur afer each character. You can use this option to generate the shortest possible lines, which you can use to create text on a line or similar effects. ANY Treats any character in the ContentElement object as a line break opportunity.anyString Treats any character in the ContentElement object as a line break opportunity. This value is typically used when Roman text is embedded in Asian text and it is desirable for breaks to happen in the middle of words. AUTO Bases line break opportunities on Unicode character properties.autoString Bases line break opportunities on Unicode character properties. This setting implements the Unicode line breaking properties defined by the Unicode Standard Annex #14. Article on Unicode line breaking properties.NONE Treats no characters in the ContentElement object as line break opportunities.noneString Treats no characters in the ContentElement object as line break opportunities. DigitWidth The DigitWidth class is an enumeration of constant values used in setting the digitWidth property of the ElementFormat class.Object The DigitWidth class is an enumeration of constant values used in setting the digitWidth property of the ElementFormat class. flash.text.engine.ElementFormat.digitWidthDEFAULT Used to specify default digit width.defaultString Used to specify default digit width. The results are font-dependent; characters use the settings specified by the font designer without any features applied. PROPORTIONAL Used to specify proportional digit width.proportionalString Used to specify proportional digit width. TABULAR Used to specify tabular digit width.tabularString Used to specify tabular digit width. CFFHinting The CFFHinting class defines values for cff hinting in the FontDescription class.Object The CFFHinting class defines values for cff hinting in the FontDescription class.

Hinting adjusts the display of an outline font so it lines up with the pixel grid. At small screen sizes, hinting produces a clear, legible text for human readers.

flash.text.engine.FontDescriptionHORIZONTAL_STEM Fits strong horizontal stems to the pixel grid for improved readability.horizontalStemString Fits strong horizontal stems to the pixel grid for improved readability. This constant is used in setting the cffHinting property of the FontDescription class. Use the syntax CFFHinting.HORIZONTAL_STEM.

Note: Not recommended for animation.

flash.text.engine.FontDescription.cffHinting
NONE No hinting is applied.noneString No hinting is applied. Horizontal stems in the glyphs are not forced to the pixel grid. This constant is used in setting the cffHinting property of the FontDescription class. Recommended setting for animation or for large font sizes. Use the syntax CFFHinting.NONE. flash.text.engine.FontDescription.cffHinting
Kerning The Kerning class is an enumeration of constant values used with ElementFormat.kerning.Object The Kerning class is an enumeration of constant values used with ElementFormat.kerning. ElementFormat.kerningAUTO Used to indicate that kerning is enabled except where inappropriate in Asian typography.autoString Used to indicate that kerning is enabled except where inappropriate in Asian typography. Kerning is applied between two characters if neither is Kanji, Hiragana, or Katakana. OFF Used to indicate kerning is disabled.offString Used to indicate kerning is disabled. ON Used to indicate kerning is enabled.onString Used to indicate kerning is enabled. TextLineMirrorRegion The TextLineMirrorRegion class represents a portion of a text line wherein events are mirrored to another event dispatcher.Object The TextLineMirrorRegion class represents a portion of a text line wherein events are mirrored to another event dispatcher.

After normal event-dispatching for a text line finishes, if the line is valid and event propagation has not been stopped, events are re dispatched to the mirror regions of the line.

Mirroring of mouse events is a special case. Because mirror regions aren't actually display objects, mouseOver and mouseOut events are simulated for them. The rollOver and rollOut events are not simulated. All naturally occuring mouseOver, mouseOut, rollOver and rollOut events (whether targetted at the text line or at children of the text line) are ignored - they are not mirrored.

You cannot create a TextLineMirrorRegion object directly from ActionScript code. If you call new TextLineMirrorRegion(), an exception is thrown. A TextLineMirrorRegion is created and associated with a text line when that text line is created from a ContentElement object with an event mirror set.

The TextLineMirrorRegion class is final; it cannot be subclassed.

This example displays a block of text with mirror regions that turn red when you click them. package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextLine; import flash.text.engine.TextElement; import flash.text.engine.ElementFormat; import flash.text.engine.FontDescription; import flash.text.engine.ContentElement; import flash.text.engine.GroupElement; import flash.text.engine.TextLineMirrorRegion; import flash.events.MouseEvent; import flash.events.EventDispatcher; import flash.ui.Mouse; public class TextLineMirrorRegionExample extends Sprite { var myEvent:EventDispatcher = new EventDispatcher(); var fontDescription:FontDescription = new FontDescription(); var textBlock:TextBlock = new TextBlock(); public function TextLineMirrorRegionExample():void { fontDescription.fontWeight = "bold"; var blackFormat:ElementFormat = new ElementFormat(); blackFormat.fontSize = 18; blackFormat.color = 0x000000; blackFormat.fontDescription = fontDescription; var textElement1 = new TextElement("Click on different parts of me to find the ", blackFormat); var textElement2 = new TextElement("mirror regions",blackFormat); var textElement3 = new TextElement(". If I am a mirror region, I'll ",blackFormat); var textElement4 = new TextElement("turn red",blackFormat); var textElement5 = new TextElement(".",blackFormat); myEvent.addEventListener("click", clickHandler); myEvent.addEventListener("mouseOut", mouseOutHandler); myEvent.addEventListener("mouseOver", mouseOverHandler); var groupVector:Vector.<ContentElement> = new Vector.<ContentElement>; groupVector.push(textElement1, textElement2, textElement3, textElement4, textElement5); var groupElement:GroupElement = new GroupElement(groupVector); textElement2.eventMirror=myEvent; textElement4.eventMirror=myEvent; textBlock.content = groupElement; createLines(textBlock); } private function clickHandler(event:MouseEvent):void { var redFormat:ElementFormat = new ElementFormat(); redFormat.color = 0xCC0000; redFormat.fontSize = 18; redFormat.fontDescription = fontDescription; var line:TextLine = event.target as TextLine; var region:TextLineMirrorRegion = line.getMirrorRegion(myEvent); region.element.elementFormat = redFormat; createLines(textBlock); } private function mouseOverHandler(event:MouseEvent):void { Mouse.cursor = "button"; } private function mouseOutHandler(event:MouseEvent):void { Mouse.cursor = "arrow"; } private function createLines(textBlock:TextBlock):void { var purgeLine:TextLine = textBlock.firstLine; while (purgeLine) { removeChild (purgeLine); purgeLine = purgeLine.nextLine; } var lineWidth:Number = 150; var xPos:Number = 15.0; var yPos:Number = 20.0; var textLine:TextLine = textBlock.createTextLine (null, lineWidth); while (textLine) { textLine.x = xPos; textLine.y = yPos; yPos += textLine.height + 2; addChild (textLine); textLine = textBlock.createTextLine (textLine, lineWidth); } } } }
ContentElement.eventMirrorTextBlock.createTextLine()TextLine.mirrorRegionsbounds The bounds of the mirror region, relative to the text line.flash.geom:Rectangle The bounds of the mirror region, relative to the text line. element The ContentElement object from which the mirror region was derived.flash.text.engine:ContentElementThe TextLine to which this element belongs is not valid. IllegalOperationErrorflash.errors:IllegalOperationError The ContentElement object from which the mirror region was derived. mirror The EventDispatcher object to which events affecting the mirror region are mirrored.flash.events:EventDispatcher The EventDispatcher object to which events affecting the mirror region are mirrored. This includes mouse events that specifically occur in the mirror region, and all other events that target the text line. nextRegion The next TextLineMirrorRegion in the set derived from the text element, or null if the current region is the last mirror region in the set.flash.text.engine:TextLineMirrorRegion The next TextLineMirrorRegion in the set derived from the text element, or null if the current region is the last mirror region in the set. May be on the same line or on another text line. previousRegion The previous TextLineMirrorRegion in the set derived from the text element, or null if the current region is the first mirror region in the set.flash.text.engine:TextLineMirrorRegion The previous TextLineMirrorRegion in the set derived from the text element, or null if the current region is the first mirror region in the set. May be on the same line or on another text line. textLine The TextLine containing this mirror region.flash.text.engine:TextLine The TextLine containing this mirror region.
LineJustification The LineJustification class is an enumeration of constant values used in setting the lineJustfication property of the TextJustifier subclasses.Object The LineJustification class is an enumeration of constant values used in setting the lineJustfication property of the TextJustifier subclasses. TextJustifier.lineJustificationALL_BUT_LAST Justify all but the last line.allButLastString Justify all but the last line. ALL_INCLUDING_LAST Justify all lines.allIncludingLastString Justify all lines. UNJUSTIFIED Do not justify lines.unjustifiedString Do not justify lines. SpaceJustifier The SpaceJustifier class represents properties that control the justification options for text lines in a text block.flash.text.engine:TextJustifier The SpaceJustifier class represents properties that control the justification options for text lines in a text block.

Use the constructor new SpaceJustifier() to create a SpaceJustifier object before setting its properties. Setting the properties of a SpaceJustifier object after you apply it to a TextBlock does not invalidate the TextBlock.

The following example uses letter spacing and justifies all of a block of text except for the last line. package { import flash.display.Sprite; import flash.text.engine.TextBlock; import flash.text.engine.TextElement; import flash.text.engine.TextLine; import flash.text.engine.ElementFormat; import flash.text.engine.SpaceJustifier; import flash.text.engine.LineJustification; public class SpaceJustifierExample extends Sprite { public function SpaceJustifierExample():void { var str:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut " + "enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " + "aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit " + "in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur " + "sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " + "mollit anim id est laborum."; var format:ElementFormat = new ElementFormat(null, 12, 0xCC0000); var textElement:TextElement = new TextElement(str, format); var spaceJustifier:SpaceJustifier = new SpaceJustifier("en", LineJustification.ALL_BUT_LAST); spaceJustifier.letterSpacing = true; var textBlock:TextBlock = new TextBlock(); textBlock.content = textElement; textBlock.textJustifier = spaceJustifier; createLines(textBlock); } private function createLines(textBlock:TextBlock):void { var yPos = 20; var textLine:TextLine = textBlock.createTextLine (null, 150); while (textLine) { addChild(textLine); textLine.x = 15; yPos += textLine.textHeight+2; textLine.y = yPos; textLine = textBlock.createTextLine(textLine, 150); } } } }
LineJustificationTextBlock.textJustifierTextJustifierSpaceJustifier Creates a SpaceJustifier object.The locale specified is null or too short to represent a valid locale. ArgumentErrorArgumentErrorThe lineJustification specified is not a member of LineJustification. ArgumentErrorArgumentErrorlocaleStringenThe locale to determine the justification rules. The default value is "en". lineJustificationStringunjustifiedThe type of line justification for the paragraph. Use LineJustification constants for this property. The default value is LineJustification.UNJUSTIFIED. letterSpacingBooleanfalseSpecifies whether to use letter spacing during justification. The default value is false. Creates a SpaceJustifier object. The LineJustification class contains constants for specifying the types of line justification that you can apply. LineJustificationclone Constructs a cloned copy of the SpaceJustifier.A copy of the SpaceJustifier object. flash.text.engine:TextJustifier Constructs a cloned copy of the SpaceJustifier. letterSpacing Specifies whether to use letter spacing during justification.Boolean Specifies whether to use letter spacing during justification.

The default value is false

maximumSpacing Specifies the maximum spacing (as a multiplier of the width of a normal space) between words to use during justification.NumberThe value specified is less than optimumSpacing. ArgumentErrorArgumentError Specifies the maximum spacing (as a multiplier of the width of a normal space) between words to use during justification. If letterSpacing is true, letter spacing will be used after the spaces between words reach the maximum. If letterSpacing is false, the spaces between words will be expanded beyond the maximum.

The default value is 1.5

minimumSpacing Specifies the minimum spacing (as a multiplier of the width of a normal space) between words to use during justification.NumberThe value specified is less than zero or greater than optimumSpacing. ArgumentErrorArgumentError Specifies the minimum spacing (as a multiplier of the width of a normal space) between words to use during justification.

The default value is 0.5

optimumSpacing Specifies the optimum spacing (as a multiplier of the width of a normal space) between words to use during justification.NumberThe value specified is less than minimumSpacing or greater than maximumSpacing. ArgumentErrorArgumentError Specifies the optimum spacing (as a multiplier of the width of a normal space) between words to use during justification.

The default value is 1.0