ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Hide Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes

Language Reference only
Filters: AIR 32.0 and earlier, Flash Player 32.0 and earlier, Flash Lite 4
Flex 4.6 and earlier, Flash Pro CS6 and earlier
Hide Filters
flash.text.engine 

TextBlock  - AS3

Packagesx

Top Level
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

Language Elements

Global Constants
Global Functions
Operators
Statements, Keywords & Directives
Special Types

Appendixes

What's New
Compiler Errors
Compiler Warnings
Run-Time Errors
Migrating to ActionScript 3
Supported Character Sets
MXML Only Tags
Motion XML Elements
Timed Text Tags
List of deprecated elements
Accessibility Implementation Constants
How to Use ActionScript Examples
Legal notices
Packageflash.text.engine
Classpublic final class TextBlock
InheritanceTextBlock Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

View the examples

More examples

Related API Elements



Public Properties
 PropertyDefined By
  applyNonLinearFontScaling : Boolean
Specifies that you want to enhance screen appearance at the expense of what-you-see-is-what-you-get (WYSIWYG) print fidelity.
TextBlock
  baselineFontDescription : FontDescription
The font used to determine the baselines for all the lines created from the block, independent of their content.
TextBlock
  baselineFontSize : Number
The font size used to calculate the baselines for the lines created from the block.
TextBlock
  baselineZero : String
Specifies which baseline is at y=0 for lines created from this block.
TextBlock
  bidiLevel : int
Specifies the bidirectional paragraph embedding level of the text block.
TextBlock
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  content : ContentElement
Holds the contents of the text block.
TextBlock
  firstInvalidLine : flash.text.engine:TextLine
[read-only] Identifies the first line in the text block in which TextLine.validity is not equal to TextLineValidity.VALID.
TextBlock
  firstLine : flash.text.engine:TextLine
[read-only] The first TextLine in the TextBlock, if any.
TextBlock
  lastLine : flash.text.engine:TextLine
[read-only] The last TextLine in the TextBlock, if any.
TextBlock
  lineRotation : String
Rotates the text lines in the text block as a unit.
TextBlock
  tabStops : Vector.<flash.text.engine:TabStop>
Specifies the tab stops for the text in the text block, in the form of a Vector of TabStop objects.
TextBlock
  textJustifier : flash.text.engine:TextJustifier
Specifies the TextJustifier to use during line creation.
TextBlock
  textLineCreationResult : String
[read-only] Indicates the result of a createTextLine() operation.
TextBlock
  userData : *
Provides a way for the application to associate arbitrary data with the text block.
TextBlock
Public Methods
 MethodDefined By
  
TextBlock(content:ContentElement = null, tabStops:Vector.<flash.text.engine:TabStop> = null, textJustifier:flash.text.engine:TextJustifier = null, lineRotation:String = "rotate0", baselineZero:String = "roman", bidiLevel:int = 0, applyNonLinearFontScaling:Boolean = true, baselineFontDescription:FontDescription = null, baselineFontSize:Number = 12.0)
Creates a TextBlock object
TextBlock
  
createTextLine(previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
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.
TextBlock
  
Dumps the underlying contents of the TextBlock as an XML string.
TextBlock
  
findNextAtomBoundary(afterCharIndex:int):int
Finds the index of the next atom boundary from the specified character index, not including the character at the specified index.
TextBlock
  
findNextWordBoundary(afterCharIndex:int):int
Finds the index of the next word boundary from the specified character index, not including the character at the specified index.
TextBlock
  
Finds the index of the previous atom boundary to the specified character index, not including the character at the specified index.
TextBlock
  
Finds the index of the previous word boundary to the specified character index, not including the character at the specified index.
TextBlock
  
Returns the TextLine containing the character specified by the charIndex parameter.
TextBlock
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
recreateTextLine(textLine:flash.text.engine:TextLine, previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
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.
TextBlock
  
Instructs the text block to release all the temporary data associated with the creation of text lines.
TextBlock
  
Removes a range of text lines from the list of lines maintained by the TextBlock.
TextBlock
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

applyNonLinearFontScaling

property
applyNonLinearFontScaling:Boolean

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.



Implementation
    public function get applyNonLinearFontScaling():Boolean
    public function set applyNonLinearFontScaling(value:Boolean):void

baselineFontDescription

property 
baselineFontDescription:FontDescription

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.



Implementation
    public function get baselineFontDescription():FontDescription
    public function set baselineFontDescription(value:FontDescription):void

Related API Elements

baselineFontSize

property 
baselineFontSize:Number

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.



Implementation
    public function get baselineFontSize():Number
    public function set baselineFontSize(value:Number):void

Throws
ArgumentError — The baselineFontSize specified is less than 0.

Related API Elements

baselineZero

property 
baselineZero:String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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 valueDescription
TextBaseline.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.



Implementation
    public function get baselineZero():String
    public function set baselineZero(value:String):void

Throws
ArgumentError — If set to any value which is not a member of TextBaseline.

Related API Elements

bidiLevel

property 
bidiLevel:int

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

Specifies the bidirectional paragraph embedding level of the text block. In general, use 0 for LTR paragraphs (English, Japanese, etc) and 1 for RTL paragraphs (Arabic, Hebrew, etc). The use of values other than 0 or 1 is reserved for special cases - see UAX#9, "Unicode Bidirectional Algorithm" (http://www.unicode.org/reports/tr9/) for details.

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.



Implementation
    public function get bidiLevel():int
    public function set bidiLevel(value:int):void

Throws
ArgumentError — If set to a value which is less than 0.

Related API Elements


Example  ( How to use this example )
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);   
        }
    }
}

content

property 
content:ContentElement

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.



Implementation
    public function get content():ContentElement
    public function set content(value:ContentElement):void

Throws
ArgumentError — If set to a value which is not a known subclass of ContentElement.
 
ArgumentError — The value specified is already a member of a group.

Related API Elements

firstInvalidLine

property 
firstInvalidLine:flash.text.engine:TextLine  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

Identifies the first line in the text block in which TextLine.validity is not equal to TextLineValidity.VALID.

The default value is null.



Implementation
    public function get firstInvalidLine():flash.text.engine:TextLine

Related API Elements

firstLine

property 
firstLine:flash.text.engine:TextLine  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

The first TextLine in the TextBlock, if any.

The default value is null.



Implementation
    public function get firstLine():flash.text.engine:TextLine

Related API Elements

lastLine

property 
lastLine:flash.text.engine:TextLine  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

The last TextLine in the TextBlock, if any.

The default value is null.



Implementation
    public function get lastLine():flash.text.engine:TextLine

Related API Elements

lineRotation

property 
lineRotation:String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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 valueDescription
TextRotation.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.



Implementation
    public function get lineRotation():String
    public function set lineRotation(value:String):void

Throws
ArgumentError — If set to any value which is not a member of TextRotation.
 
ArgumentError — If set to TextRotation.AUTO.

More examples

Related API Elements


Example  ( How to use this example )
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;
            }        
        }
    }
}

tabStops

property 
tabStops:Vector.<flash.text.engine:TabStop>

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.



Implementation
    public function get tabStops():Vector.<flash.text.engine:TabStop>
    public function set tabStops(value:Vector.<flash.text.engine:TabStop>):void

Throws
ArgumentError — The tabStops specified contain null elements.
 
ArgumentError — The tabStops specified are not sorted by increasing position.

Related API Elements

textJustifier

property 
textJustifier:flash.text.engine:TextJustifier

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.



Implementation
    public function get textJustifier():flash.text.engine:TextJustifier
    public function set textJustifier(value:flash.text.engine:TextJustifier):void

Throws
ArgumentError — If set to a value which is not a known subclass of TextJustifier.

More examples

Related API Elements

textLineCreationResult

property 
textLineCreationResult:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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 valueDescription
TextLineCreationResult.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.



Implementation
    public function get textLineCreationResult():String

Related API Elements

userData

property 
public var userData:*

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Constructor Detail

TextBlock

()Constructor
public function TextBlock(content:ContentElement = null, tabStops:Vector.<flash.text.engine:TabStop> = null, textJustifier:flash.text.engine:TextJustifier = null, lineRotation:String = "rotate0", baselineZero:String = "roman", bidiLevel:int = 0, applyNonLinearFontScaling:Boolean = true, baselineFontDescription:FontDescription = null, baselineFontSize:Number = 12.0)

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

Creates a TextBlock object

Parameters
content:ContentElement (default = null) — The contents of the text block.
 
tabStops:Vector.<flash.text.engine:TabStop> (default = null) — The tab stops for the text in the text block.
 
textJustifier:flash.text.engine:TextJustifier (default = null) — The 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.
 
lineRotation:String (default = "rotate0") — The rotation applied to the text lines generated from the text block as units.
 
baselineZero:String (default = "roman") — Specifies which baseline is at y=0 for all lines in the block.
 
bidiLevel:int (default = 0) — The default bidirectional embedding level of the text in the text block.
 
applyNonLinearFontScaling:Boolean (default = true) — Specifies that you want to enhance screen appearance at the expense of WYSIWYG print fidelity.
 
baselineFontDescription:FontDescription (default = null) — Specifies a font description from which to derive line baselines for all lines in the block.
 
baselineFontSize:Number (default = 12.0) — Specifies the size to use with the baselineFontDescription. This parameter is ignored if baselineFontDescription is null.

Throws
ArgumentError — The content specified is not a known subclass of ContentElement.
 
ArgumentError — The content specified is already a member of a group.
 
ArgumentError — The lineRotation specified is not a member of TextRotation.
 
ArgumentError — The baselineZero specified is not a member of TextBaseline.
 
ArgumentError — The bidiLevel specified is less than 0.
 
ArgumentError — The tabStops specified contain null elements.
 
ArgumentError — The tabStops specified are not sorted by increasing position.
 
ArgumentError — The baselineFontSize specified is less than 0.

Related API Elements

Method Detail

createTextLine

()method
public function createTextLine(previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Parameters

previousLine:flash.text.engine:TextLine (default = null) — Specifies the previously broken line after which breaking is to commence. Can be null when breaking the first line.
 
width:Number (default = 1000000) — Specifies the desired width of the line in pixels. The actual width may be less.
 
lineOffset:Number (default = 0.0) — An 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.
 
fitSomething:Boolean (default = false) — An 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).

Returns
flash.text.engine:TextLine — A 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.

Throws
ArgumentError — If the TextLine specified by previousLine is not valid.
 
ArgumentError — If the TextLine specified by previousLine is owned by a different TextBlock.
 
ArgumentError — If width is less than zero, unless fitSomething is true.
 
ArgumentError — If width is greater than TextLine.MAX_LINE_WIDTH.
 
IllegalOperationError — If one or more elements in the content of the text block has a null ElementFormat.

Related API Elements


Example  ( How to use this example )

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);
            }
        }
    }
}

dump

()method 
public function dump():String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

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.

Returns
String

Related API Elements

findNextAtomBoundary

()method 
public function findNextAtomBoundary(afterCharIndex:int):int

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Parameters

afterCharIndex:int — Specifies the index of the character from which to search for the next atom boundary.

Returns
int — The index of the next atom boundary from the specified character index.

Throws
RangeError — The index specified is out of range.
 
IllegalOperationError — The TextLine to which the indexed character belongs is not valid.

Related API Elements

findNextWordBoundary

()method 
public function findNextWordBoundary(afterCharIndex:int):int

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Parameters

afterCharIndex:int — Specifies the index of the character from which to search for the next word boundary.

Returns
int — The index of the next word boundary from the specified character index.

Throws
RangeError — The index specified is out of range.
 
IllegalOperationError — The TextLine to which the indexed character belongs is not valid.

findPreviousAtomBoundary

()method 
public function findPreviousAtomBoundary(beforeCharIndex:int):int

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Parameters

beforeCharIndex:int — Specifies the index of the character from which to search for the previous atom boundary.

Returns
int — The index of the previous atom boundary to the specified character index.

Throws
RangeError — The index specified is out of range.
 
IllegalOperationError — The TextLine to which the indexed character belongs is not valid.

Related API Elements

findPreviousWordBoundary

()method 
public function findPreviousWordBoundary(beforeCharIndex:int):int

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Parameters

beforeCharIndex:int — Specifies the index of the character from which to search for the previous word boundary.

Returns
int — The index of the previous word boundary to the specified character index.

Throws
RangeError — The index specified is out of range.
 
IllegalOperationError — The TextLine to which the indexed character belongs is not valid.

getTextLineAtCharIndex

()method 
public function getTextLineAtCharIndex(charIndex:int):flash.text.engine:TextLine

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

Returns the TextLine containing the character specified by the charIndex parameter.

Parameters

charIndex:int — The zero-based index value of the character (for example, the first character is 0, the second character is 1, and so on).

Returns
flash.text.engine:TextLine — The TextLine containing the character at charIndex.

Throws
RangeError — The character index specified is out of range.

recreateTextLine

()method 
public function recreateTextLine(textLine:flash.text.engine:TextLine, previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2, Flash Lite 4

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.

Parameters

textLine:flash.text.engine:TextLine — Specifies a previously created TextLine to be re-used.
 
previousLine:flash.text.engine:TextLine (default = null) — Specifies the previously broken line after which breaking is to commence. Can be null when breaking the first line.
 
width:Number (default = 1000000) — Specifies the desired width of the line in pixels. The actual width may be less.
 
lineOffset:Number (default = 0.0) — An 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.
 
fitSomething:Boolean (default = false) — An 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).

Returns
flash.text.engine:TextLine — A 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.

Throws
ArgumentError — If textLine is null.
 
ArgumentError — If the TextLine specified by previousLine is not valid.
 
ArgumentError — If the TextLine specified by previousLine is owned by a different TextBlock.
 
ArgumentError — If the TextLine specified by previousLine is also specified by textLine.
 
ArgumentError — If width is less than zero, unless fitSomething is true.
 
ArgumentError — If width is greater than TextLine.MAX_LINE_WIDTH.
 
IllegalOperationError — If one or more elements in the content of the text block has a null ElementFormat.

Related API Elements


Example  ( How to use this example )

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;

releaseLineCreationData

()method 
public function releaseLineCreationData():void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2, Flash Lite 4

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.

Related API Elements

releaseLines

()method 
public function releaseLines(firstLine:flash.text.engine:TextLine, lastLine:flash.text.engine:TextLine):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5, Flash Lite 4

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.

Parameters

firstLine:flash.text.engine:TextLine — Specifies the first line to release.
 
lastLine:flash.text.engine:TextLine — Specifies the last line to release.


Throws
ArgumentError — If the TextLine specified by firstLine or lastLine is not in the list of text lines maintained by the text block.

Related API Elements

TextBlockExample.as

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();
        }
    }
}