用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隐藏过滤条件
flash.text.engine 

TextBlock  - AS3

x

顶级
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

语言元素

全局常量
全局函数
运算符
语句、关键字和指令
特殊类型

附录

新增内容
编译器错误
编译器警告
运行时错误
迁移到 ActionScript 3
支持的字符集
仅适用于 MXML 的标签
Motion XML 元素
Timed Text 标记
不推荐使用的元素的列表
AccessibilityImplementation 常量
如何使用 ActionScript 示例
法律声明
flash.text.engine
public final class TextBlock
继承TextBlock Inheritance Object

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

TextBlock 类是用于创建 TextLine 对象的工厂,可以通过将其放在显示列表中来进行呈现。

TextBlock 类用于包含单个段落,因为 Unicode 双向算法和换行算法一次操作一个段落。对于包含多个文本段落的应用程序,请使用标记语言或文本分析将文本拆分为多个段落,并为每个段落创建一个 TextBlock。

TextBlock 对象在 content 属性中存储其内容,该属性是 ContentElement 类的一个实例。因为无法创建 ContentElement 类的实例,所以请将 content 设置为该类的以下其中一个子类的实例:TextElement、GraphicElement 或 GroupElement。请将 TextElement 用于纯文本内容、将 GraphicElement 用于图像或图形内容、将 GroupElement 用于包含 TextElement、GraphicElement 和其他 GroupElement 对象的组合的内容。有关管理格式化文本串、嵌入的子串以及图形元素的详细信息,请参阅 ContentElement 类及其子类。

在创建 TextBlock 实例并设置 content 属性后,可以调用 createTextLine() 方法以创建作为 TextLine 类的实例的文本行。

查看示例

相关 API 元素



公共属性
 属性由以下参数定义
  applyNonLinearFontScaling : Boolean
指定想要以降低所见即所得 (WYSIWYG) 输出保真度为代价来增强屏幕外观。
TextBlock
  baselineFontDescription : FontDescription
用于确定从块中创建的所有行的基线的字体,这与行内容无关。
TextBlock
  baselineFontSize : Number
用于计算从块中创建的行的基线的字体大小。
TextBlock
  baselineZero : String
指定对于从此块中创建的行位置为 y=0 的基线。
TextBlock
  bidiLevel : int
指定文本块的双向段落嵌入级别。
TextBlock
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  content : ContentElement
容纳文本块的内容。
TextBlock
  firstInvalidLine : flash.text.engine:TextLine
[只读] 标识文本块内 TextLine.validity 不是 TextLineValidity.VALID 的第一行。
TextBlock
  firstLine : flash.text.engine:TextLine
[只读] TextBlock 中的第一个 TextLine,如果有。
TextBlock
  lastLine : flash.text.engine:TextLine
[只读] TextBlock 中的最后一个 TextLine,如果有。
TextBlock
  lineRotation : String
作为一个单元旋转文本块中的文本行。
TextBlock
  tabStops : Vector.<flash.text.engine:TabStop>
指定文本块中文本的 Tab 停靠位,用 TabStop 对象的矢量形式表示。
TextBlock
  textJustifier : flash.text.engine:TextJustifier
指定在创建行的过程中要使用的 TextJustifier。
TextBlock
  textLineCreationResult : String
[只读] 表示 createTextLine() 操作的结果。
TextBlock
  userData : *
为应用程序提供一种将任意数据与文本块相关联的方法。
TextBlock
公共方法
 方法由以下参数定义
  
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)
创建一个 TextBlock 对象
TextBlock
  
createTextLine(previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
表示文本块从其内容中创建一行文本,从 previousLine 参数指定的点处开始并在 width 参数指定的点处换行。
TextBlock
  
将 TextBlock 的基础内容转储为 XML 字符串。
TextBlock
  
findNextAtomBoundary(afterCharIndex:int):int
从指定的字符索引查找下个 atom 边界的索引,不包括指定索引中的字符。
TextBlock
  
findNextWordBoundary(afterCharIndex:int):int
从指定字符索引处开始查找下一个文字边界的索引,不包括指定索引处的字符。
TextBlock
  
查找指定字符索引之前的上一个 atom 边界的索引,不包括指定索引处的字符。
TextBlock
  
查找指定字符索引之前的上一个文字边界的索引,不包括指定索引处的字符。
TextBlock
  
返回包含由 charIndex 参数指定的字符的 TextLine。
TextBlock
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
表示指定的属性是否存在、是否可枚举。
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
表示文本块可以重用现有的文本行,以从其内容中创建一行文本,从 previousLine 参数指定的点处开始并在 width 参数指定的点处换行。
TextBlock
  
表示文本块释放与文本行创建相关的所有临时数据。
TextBlock
  
从 TextBlock 保留的行列表中删除一系列文本行。
TextBlock
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
属性详细信息

applyNonLinearFontScaling

属性
applyNonLinearFontScaling:Boolean

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

指定想要以降低所见即所得 (WYSIWYG) 输出保真度为代价来增强屏幕外观。对于在设备字体渲染期间不支持子像素字型定位、但支持非线性缩放的平台和字体,将此属性设置为 true 可允许以降低 WYSIWYG 输出保真度为代价来使用那些度量。非线性字体缩放的作用方式是,有选择地缩放单个字型的宽度,以隐藏像素贴紧导致的不美观的间隙。

在支持子像素字型定位的平台上,忽略此标志。

此标志对嵌入的字体呈现无效。

默认值为 true



实现
    public function get applyNonLinearFontScaling():Boolean
    public function set applyNonLinearFontScaling(value:Boolean):void

baselineFontDescription

属性 
baselineFontDescription:FontDescription

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

用于确定从块中创建的所有行的基线的字体,这与行内容无关。基线取决于字体和字体大小。

默认值为 null。如果基线字体为 null,则将忽略基线字体大小,并且任何给定行的基线将基于行中最大文本的字体和大小。如果指定 baselineFontDescriptionbaselineFontSize,它们将决定文本块中所有行的基线,而与行内容无关。这种组合在中文版式中最常用。



实现
    public function get baselineFontDescription():FontDescription
    public function set baselineFontDescription(value:FontDescription):void

相关 API 元素

baselineFontSize

属性 
baselineFontSize:Number

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

用于计算从块中创建的行的基线的字体大小。基线取决于字体和字体大小。

默认值为 12。如果基线字体为 null,则将忽略基线字体大小,并且任何给定行的基线将基于行中最大文本的字体和大小。



实现
    public function get baselineFontSize():Number
    public function set baselineFontSize(value:Number):void

引发
ArgumentError — 指定的 baselineFontSize 小于 0。

相关 API 元素

baselineZero

属性 
baselineZero:String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

指定对于从此块中创建的行位置为 y=0 的基线。此属性的有效值包括在 TextBaseline 类的成员中。

默认值为 TextBaseline.ROMAN

要设置此属性的值,请使用下列字符串值:

字符串值说明
TextBaseline.ROMAN行的罗马字基线位于 y=0 处。
TextBaseline.ASCENT行的上缘基线位于 y=0 处。
TextBaseline.DESCENT行的下缘基线位于 y=0 处。
TextBaseline.IDEOGRAPHIC_TOP行的表意顶部基线位于 y=0 处。
TextBaseline.IDEOGRAPHIC_CENTER行的表意中心基线位于 y=0 处。
TextBaseline.IDEOGRAPHIC_BOTTOM行的表意底部基线位于 y=0 处。



实现
    public function get baselineZero():String
    public function set baselineZero(value:String):void

引发
ArgumentError — 如果设置的值不是 TextBaseline 的成员。

相关 API 元素

bidiLevel

属性 
bidiLevel:int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

指定文本块的双向段落嵌入级别。通常情况下,0 用于 LTR 段落(英语、日语等),1 用于 RTL 段落(阿拉伯语、希伯来语等)。只有特殊情况才使用 0 和 1 之外的值 - 请参阅“UAX#9: Unicode Bidirectional Algorithm”(http://www.unicode.org/reports/tr9/) 以了解详细信息。

默认值为 0。

如果修改 bidiLevel,则会将所有以前断开的行的有效性更改为 TextLineValidity.INVALID。更改 bidiLevel 后,firstInvalidLine 属性将等同于 firstLine 属性,并且您必须重新断开 TextBlock 中的所有行。



实现
    public function get bidiLevel():int
    public function set bidiLevel(value:int):void

引发
ArgumentError — 如果设置为小于 0 的值。

相关 API 元素


示例  ( 如何使用本示例 )
此示例首先将 bidiLevel 设置为偶数来呈现文本字符串(逻辑顺序:a、b、c、alef、bet、gimel),然后将其设置为基数来呈现该字符串。
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

属性 
content:ContentElement

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

容纳文本块的内容。因为 ContentElement 是一个基类,所以请为 content 分配一个以下 ContentElement 子类的实例:TextElement、GraphicElement 或 GroupElement。TextElement 对象包含一个 String,GraphicElement 对象包含一个 DisplayObject,GroupElement 包含一个 Vector 对象,该对象包含一个或多个 TextElement、GraphicElement 或其他 GroupElement 对象。请将 TextElement 用于一段同源文本,将 GraphicElement 用于图形,将 GroupElement 用于文本和图形元素或这些元素的多个实例的组合以及其他 GroupElement 对象。

默认值为 null

如果修改 content 属性,则会将所有以前创建的行的 validity 更改为 TextLineValidity.INVALID。更改 content 后,firstInvalidLine 属性将等同于 firstLine 属性,并且您必须重新断开 TextBlock 中的所有行。



实现
    public function get content():ContentElement
    public function set content(value:ContentElement):void

引发
ArgumentError — 如果设置的值不是 ContentElement 的已知子类。
 
ArgumentError — 指定的 value 已经是组成员。

相关 API 元素

firstInvalidLine

属性 
firstInvalidLine:flash.text.engine:TextLine  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

标识文本块内 TextLine.validity 不是 TextLineValidity.VALID 的第一行。

默认值为 null



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

相关 API 元素

firstLine

属性 
firstLine:flash.text.engine:TextLine  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

TextBlock 中的第一个 TextLine,如果有。

默认值为 null



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

相关 API 元素

lastLine

属性 
lastLine:flash.text.engine:TextLine  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

TextBlock 中的最后一个 TextLine,如果有。

默认值为 null



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

相关 API 元素

lineRotation

属性 
lineRotation:String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

作为一个单元旋转文本块中的文本行。在设置 lineRotation 之后调用 createTextLine() 方法,以使设置生效。默认值为 TextRotation.ROTATE_0

任何字型的最终旋转都取决于 ElementFormat.textRotationContentElement.textRotationTextBlock.lineRotation 的值。

TextBlock.lineRotation 通常用于亚洲文字。要创建日文垂直文本段落,请执行以下操作:

  1. TextBlock.lineRotation 属性设置为 TextRotation.ROTATE_90
  2. 将内容的 ElementFormat.textRotation 属性保留为默认值 TextRotation.AUTO

使用在 TextRotation 类中定义的以下常量设置此属性的值:

字符串值说明
TextRotation.ROTATE_0不旋转行。
TextRotation.ROTATE_90将行顺时针旋转 90 度。
TextRotation.ROTATE_180将行旋转 180 度。
TextRotation.ROTATE_270将行顺时针旋转 270 度。
TextRotation.AUTO不支持。



实现
    public function get lineRotation():String
    public function set lineRotation(value:String):void

引发
ArgumentError — 如果设置的值不是 TextRotation 的成员。
 
ArgumentError — 如果设置为 TextRotation.AUTO

相关 API 元素


示例  ( 如何使用本示例 )
此示例向 TextBlock 添加日文文本并将 lineRotation 属性设置为 TextRotation.ROTATE_90 以便垂直显示行。
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

属性 
tabStops:Vector.<flash.text.engine:TabStop>

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

指定文本块中文本的 Tab 停靠位,用 TabStop 对象的矢量形式表示。

默认值为 null,意味着不指定制表位。如果不指定制表位(或者插入点在指定的最后一个制表位之外),默认情况下,运行时将创建半英寸制表符。

如果设置了 tabStops 属性,TextBlock 将制作此 Vector 的副本供内部使用。修改原始 Vector 或其内容不会影响 TextBlock。如果对 tabStops 属性进行查询,将返回此内部 Vector 的副本。同样,修改此返回的矢量或其内容不会影响 TextBlock。



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

引发
ArgumentError — 指定的 tabStops 包含 null 元素。
 
ArgumentError — 指定的 tabStops 不是按位置增加顺序排序的。

相关 API 元素

textJustifier

属性 
textJustifier:flash.text.engine:TextJustifier

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

指定在创建行的过程中要使用的 TextJustifier。

默认值为默认构造的 TextJustifier 对象。

如果设置了 textJustifier 属性,TextBlock 将制作此对象的副本供内部使用。修改原始对象不会影响 TextBlock。如果对 textJustifier 属性进行查询,将返回此内部对象的副本。同样,修改此返回的对象不会影响 TextBlock。



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

引发
ArgumentError — 如果设置的值不是 TextJustifier 的已知子类。

相关 API 元素

textLineCreationResult

属性 
textLineCreationResult:String  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

表示 createTextLine() 操作的结果。更改该块的内容将使先前断开的行无效,并会将此属性重置为 null

默认值为 null

此属性的值包括在 TextLineCreationResult

字符串值说明
TextLineCreationResult.SUCCESS行已成功断开。
TextLineCreationResult.COMPLETE创建的新行已经与从 POSSIBLY_INVALID 转换到 VALID 的后续行完全对齐,或者是由于块中的所有文本已经断行而未创建任何行。
TextLineCreationResult.INSUFFICIENT_WIDTH由于文本无法适合指定的宽度,因此未创建任何行。



实现
    public function get textLineCreationResult():String

相关 API 元素

userData

属性 
public var userData:*

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

为应用程序提供一种将任意数据与文本块相关联的方法。数据可以是与内容相关的信息,例如修订日期或作者的姓名,或者也可以是处理过程中使用的缓存数据。

构造函数详细信息

TextBlock

()构造函数
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)

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

创建一个 TextBlock 对象

参数
content:ContentElement (default = null) — 文本块的内容。
 
tabStops:Vector.<flash.text.engine:TabStop> (default = null) — 文本块中文本的 Tab 停靠位。
 
textJustifier:flash.text.engine:TextJustifier (default = null) — 为此块创建行的过程中要使用的 TextJustifier 对象。如果未提供对齐符,则将基于英语区域设置构造默认对齐符。
 
lineRotation:String (default = "rotate0") — 作为一个单元应用于从文本块生成的文本行的旋转。
 
baselineZero:String (default = "roman") — 指定哪条基线对于块中的所有行均为 y=0。
 
bidiLevel:int (default = 0) — 文本在文本块中的默认双向嵌入级别。
 
applyNonLinearFontScaling:Boolean (default = true) — 指定想要以降低 WYSIWYG 输出保真度为代价来增强屏幕外观。
 
baselineFontDescription:FontDescription (default = null) — 指定用以推导块中所有行的行基线的字体说明。
 
baselineFontSize:Number (default = 12.0) — 指定用于 baselineFontDescription 的大小。如果 baselineFontDescriptionnull,则忽略此参数。

引发
ArgumentError — 指定的 content 不是 ContentElement 的已知子类。
 
ArgumentError — 指定的 content 已经是组成员。
 
ArgumentError — 指定的 lineRotation 不是 TextRotation 的成员。
 
ArgumentError — 指定的 baselineZero 不是 TextBaseline 的成员。
 
ArgumentError — 指定的 bidiLevel 小于 0。
 
ArgumentError — 指定的 tabStops 包含 null 元素。
 
ArgumentError — 指定的 tabStops 不是按位置增加顺序排序的。
 
ArgumentError — 指定的 baselineFontSize 小于 0。

相关 API 元素

方法详细信息

createTextLine

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

表示文本块从其内容中创建一行文本,从 previousLine 参数指定的点处开始并在 width 参数指定的点处换行。文本行是 TextLine 对象,您可以将该对象添加到显示列表中。

对文本块中已经断行的范围进行断行会更改断行区域内外的行的有效性。行的状态可能会从 VALID 更改为 INVALID 或 POSSIBLY_INVALID。如果新断开的行与状态为 POSSIBLY_INVALID 的以前断开的行完全对齐,则以前断开的行和所有以下 POSSIBLY_INVALID 行将改回 VALID 状态。已经设置为非 TextLineValidity 成员的值的各行的 validity 不会更改为 VALID,但可以更改为 INVALID。在对文本块进行任何更改后请检查 firstInvalidLine 属性,以查看要开始或继续重新换行的位置。

通过在文本中包括 Unicode 零宽度间隔 (ZWSP) 字符可以创建人工文字换行。这对泰语这样需要字典才能正确换行的语言很有用。Flash 运行时不包括这样一本词典。

为减少内存开销,在所有所需行都创建完毕后,除非预期行将需要重复断开(例如调整容器大小),此用户应该调用 releaseLineCreationData() 方法,允许文本块处理与换行相关的临时数据。

参数

previousLine:flash.text.engine:TextLine (default = null) — 指定在其后开始断开的上一个断行。在对第一行换行时可以是 null
 
width:Number (default = 1000000) — 以像素为单位指定所需的行宽度。实际宽度可能更小。
 
lineOffset:Number (default = 0.0) — 一个可选参数,以像素为单位指定行的起点和 Tab 停靠位起点之间的距离。当行未对齐但其 Tab 停靠位需要对齐时可以使用此参数。此参数的默认值为 0.0
 
fitSomething:Boolean (default = false) — 一个可选参数,表示 Flash Player 至少使一个字符适合文本行,不管指定的宽度如何(即使宽度为零或负值,在这种情况下,将导致引发异常)。

返回
flash.text.engine:TextLine — 一个文本行,如果文本块为空或指定的宽度小于下一个元素的宽度,则为 null。要区分这些情况,请检查文本块的 textLineCreationResult 属性。

引发
ArgumentError — 如果由 previousLine 指定的 TextLine 无效。
 
ArgumentError — 如果 previousLine 指定的 TextLine 由其他 TextBlock 拥有。
 
ArgumentError — 如果 width 小于零;除非 fitSomething 为 true。
 
ArgumentError — 如果 width 大于 TextLine.MAX_LINE_WIDTH
 
IllegalOperationError — 如果文本块内容中的一个或多个元素具有 null ElementFormat

相关 API 元素


示例  ( 如何使用本示例 )

本示例调用 createTextLine() 方法在文本块中创建文本行。该示例通过执行以下任务完成此操作:
  • 从 String 创建一个 TextElement 并为其指定字体大小 20
  • 创建一个 TextBlock 并为其分配 TextElement
  • 调用 createTextLine() 以从文本块创建 300 像素宽的行
  • 将每行放在舞台上 (addChild()) 并设置其位置(xy
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

()方法 
public function dump():String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

将 TextBlock 的基础内容转储为 XML 字符串。这在自动测试过程中很有用,并包括文本、格式和布局信息。

以下内容描述了输出:

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

有关每行输出的说明,请参阅 TextLine.dump() 方法。

注意:输出的内容和格式将来可能会发生更改。Adobe 不保证此方法的向后兼容性。

返回
String

相关 API 元素

findNextAtomBoundary

()方法 
public function findNextAtomBoundary(afterCharIndex:int):int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

从指定的字符索引查找下个 atom 边界的索引,不包括指定索引中的字符。atom 边界之间的字符在 TextLine 中结合成一个 atom,如“e”和组合重音符。

参数

afterCharIndex:int — 指定要从其开始搜索下一个 atom 边界的字符的索引。

返回
int — 从指定字符索引处开始的下一个 atom 边界的索引。

引发
RangeError — 指定的 index 超出范围。
 
IllegalOperationError — 索引字符所属的 TextLine 无效。

相关 API 元素

findNextWordBoundary

()方法 
public function findNextWordBoundary(afterCharIndex:int):int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

从指定字符索引处开始查找下一个文字边界的索引,不包括指定索引处的字符。文字边界的确定依据是字符的 Unicode 属性。

参数

afterCharIndex:int — 指定要从其开始搜索下一个文字边界的字符的索引。

返回
int — 从指定字符索引处开始的下一个文字边界的索引。

引发
RangeError — 指定的 index 超出范围。
 
IllegalOperationError — 索引字符所属的 TextLine 无效。

findPreviousAtomBoundary

()方法 
public function findPreviousAtomBoundary(beforeCharIndex:int):int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

查找指定字符索引之前的上一个 atom 边界的索引,不包括指定索引处的字符。atom 边界之间的字符在 TextLine 中结合成一个 atom,如“e”和组合重音符。

参数

beforeCharIndex:int — 指定要从其开始搜索上一个 atom 边界的字符的索引。

返回
int — 指定字符索引之前的上一个 atom 边界的索引。

引发
RangeError — 指定的 index 超出范围。
 
IllegalOperationError — 索引字符所属的 TextLine 无效。

相关 API 元素

findPreviousWordBoundary

()方法 
public function findPreviousWordBoundary(beforeCharIndex:int):int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

查找指定字符索引之前的上一个文字边界的索引,不包括指定索引处的字符。文字边界的确定依据是字符的 Unicode 属性。

参数

beforeCharIndex:int — 指定要从其开始搜索上一个文字边界的字符的索引。

返回
int — 指定字符索引之前的上一个文字边界的索引。

引发
RangeError — 指定的 index 超出范围。
 
IllegalOperationError — 索引字符所属的 TextLine 无效。

getTextLineAtCharIndex

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

返回包含由 charIndex 参数指定的字符的 TextLine。

参数

charIndex:int — 从零开始的字符索引值(例如,第一个字符的索引值是 0,第二个字符的索引值是 1,依此类推)。

返回
flash.text.engine:TextLine — 包含 charIndex 处的字符的 TextLine。

引发
RangeError — 指定的字符索引超出范围。

recreateTextLine

()方法 
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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2, Flash Lite 4

表示文本块可以重用现有的文本行,以从其内容中创建一行文本,从 previousLine 参数指定的点处开始并在 width 参数指定的点处换行。文本行是 TextLine 对象,您可以将该对象添加到显示列表中。通过重新使用现有的文本行,由于减少了对象创建,性能得到增强。

textLine 所在的任何文本块(如果有)释放正在重新创建的 textLine。此外,所有属性(包括从 DisplayObjectContainerInteractiveObjectDisplayObject 继承的属性)将重置为其默认值。最后,删除行的所有子项(包括图形元素和其他装饰)并删除行上的所有事件侦听器。要提高性能,这种完全重置的唯一例外情况是不从行的父项中删除其本身。

对文本块中已经断行的范围进行断行会更改断行区域内外的行的有效性。行的状态可能会从 VALID 更改为 INVALID 或 POSSIBLY_INVALID。如果新断开的行与状态为 POSSIBLY_INVALID 的以前断开的行完全对齐,则以前断开的行和所有以下 POSSIBLY_INVALID 行将改回 VALID 状态。已经设置为非 TextLineValidity 成员的值的各行的 validity 不会更改为 VALID,但可以更改为 INVALID。在对文本块进行任何更改后请检查 firstInvalidLine 属性,以查看要开始或继续重新换行的位置。

通过在文本中包括 Unicode 零宽度间隔 (ZWSP) 字符可以创建人工文字换行。这对泰语这样需要字典才能正确换行的语言很有用。Flash 运行时不包括这样一本词典。

为减少内存开销,在所有所需行都创建完毕后,除非预期行将需要重复断开(例如调整容器大小),此用户应该调用 releaseLineCreationData() 方法,允许文本块处理与换行相关的临时数据。

参数

textLine:flash.text.engine:TextLine — 指定一个以前创建的 TextLine 以供重复使用。
 
previousLine:flash.text.engine:TextLine (default = null) — 指定在其后开始断开的上一个断行。在对第一行换行时可以是 null
 
width:Number (default = 1000000) — 以像素为单位指定所需的行宽度。实际宽度可能更小。
 
lineOffset:Number (default = 0.0) — 一个可选参数,以像素为单位指定行的起点和 Tab 停靠位起点之间的距离。当行未对齐但其 Tab 停靠位需要对齐时可以使用此参数。此参数的默认值为 0.0
 
fitSomething:Boolean (default = false) — 一个可选参数,表示 Flash Player 至少使一个字符适合文本行,不管指定的宽度如何(即使宽度为零或负值,在这种情况下,将导致引发异常)。

返回
flash.text.engine:TextLine — 一个文本行,如果文本块为空或指定的宽度小于下一个元素的宽度,则为 null。要区分这些情况,请检查文本块的 textLineCreationResult 属性。

引发
ArgumentError — 如果 textLine 为 null。
 
ArgumentError — 如果由 previousLine 指定的 TextLine 无效。
 
ArgumentError — 如果 previousLine 指定的 TextLine 由其他 TextBlock 拥有。
 
ArgumentError — 如果由 previousLine 指定的 TextLine 也由 textLine 指定。
 
ArgumentError — 如果 width 小于零;除非 fitSomething 为 true。
 
ArgumentError — 如果 width 大于 TextLine.MAX_LINE_WIDTH
 
IllegalOperationError — 如果文本块内容中的一个或多个元素具有 null ElementFormat

相关 API 元素


示例  ( 如何使用本示例 )

本示例会重用 TextLine 对象 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

()方法 
public function releaseLineCreationData():void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2, Flash Lite 4

表示文本块释放与文本行创建相关的所有临时数据。要最大程度的降低应用程序的内存占用,当完成从文本块创建文本行后,您应该调用 releaseLineCreationData() 方法。但是,要最大程度的增强重新换行的性能(例如调整容器大小时),则不应该调用 releaseLineCreationData() 方法。这取决于应用程序如何平衡内存与性能。

以下是针对不希望更改的文本提出的建议的过程:初始化文本块,根据需要通常调用 createTextLine() 方法来创建所需输出,然后调用 releaseLineCreationData() 方法。

相关 API 元素

releaseLines

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5, Flash Lite 4

从 TextBlock 保留的行列表中删除一系列文本行。在没有其他引用的情况下允许将行作为垃圾回收。

将已删除行的 textBlocknextLinepreviousLine 成员设置为 null。将已删除行以及 TextBlock 中已删除行后面的所有行的有效性设置为 TextLineValidity.INVALID

参数

firstLine:flash.text.engine:TextLine — 指定要释放的第一行。
 
lastLine:flash.text.engine:TextLine — 指定要释放的最后一行。


引发
ArgumentError — 如果 firstLinelastLine 所指定的 TextLine 不在文本块所保留的文本行列表中。

相关 API 元素

TextBlockExample.as

本示例显示三个日文和英文文本的 TextBlock 段落。将日文文本从 Unicode 字符代码转换为字符串。当您单击该按钮时,本示例将文本从水平旋转为垂直或从垂直旋转为水平。
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();
        }
    }
}




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。