適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隱藏篩選
flash.text 

TextFormat  - 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 標籤
移動 XML 元素
Timed Text 標籤
不建議元素清單
AccessibilityImplementation 常數
如何使用 ActionScript 範例
法律聲明
套件flash.text
類別public class TextFormat
繼承TextFormat Inheritance Object
子類別 UITextFormat

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9, Flash Lite 4

TextFormat 類別表示字元的格式資訊。 使用 TextFormat 類別爲文字欄位建立指定的文字格式。 您可以將文字格式同時套用至靜態和動態的文字欄位。 TextFormat 類別的屬性適用於裝置和嵌入字體。 不過,對於嵌入字體,粗體和斜體文字,實際上則需要特定的字體。 如果您要在嵌入字體顯示粗體或斜體文字,便需要嵌入該字體的粗體和斜體變化。

在設定 TextFormat 物件的屬性之前,您必須使用建構函式 new TextFormat() 來建立該物件。 當您使用 TextField.defaultTextFormat 屬性或 TextField.setTextFormat() 方法將 TextFormat 物件套用到文字欄位時,只會套用其已定義的屬性。在您將文字加入到 TextField 之前使用 TextField.defaultTextFormat 屬性套用格式,並在您將文字加入到 TextField 之後使用 setTextFormat() 方法加入格式。根據預設,TextFormat 屬性為 null。因為如果您沒有對屬性提供值,Flash Player 便會使用自己的預設格式。 下列是 Flash Player 用於每一個屬性 (如果屬性的值是 null) 的預設格式:

align = "left"
blockIndent = 0
bold = false
bullet = false
color = 0x000000
font = "Times New Roman" (在 Mac OS X 上的預設字體為 Times)
indent = 0
italic = false
kerning = false
leading = 0
leftMargin = 0
letterSpacing = 0
rightMargin = 0
size = 12
tabStops = [] (空陣列)
target = "" (空字串)
underline = false
url = "" (空字串)

在每個屬性的描述中,也會對每個屬性的預設格式加以說明。

檢視範例

相關 API 元素



公用屬性
 屬性定義自
  align : String
指出段落的對齊方式。
TextFormat
  blockIndent : Object
指出區塊縮排,以像素為單位。
TextFormat
  bold : Object
會指定文字是否為粗體。
TextFormat
  bullet : Object
指出文字是項目清單的一部分。
TextFormat
  color : Object
指出文字的顏色。
TextFormat
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
  font : String
這個文字格式的文字字體名稱,以字串表示。
TextFormat
  indent : Object
指出段落中從左方邊界到第一個字元的縮排。
TextFormat
  italic : Object
指出在此文字格式中的文字是否為斜體。
TextFormat
  kerning : Object
Boolean 值,指出啟用字距微調 (true) 或停用字距微調 (false)。
TextFormat
  leading : Object
整數,表示行與行之間垂直空間的量 (稱為「行距」)。
TextFormat
  leftMargin : Object
段落的左方邊界,以像素為單位。
TextFormat
  letterSpacing : Object
數字,代表在所有字元之間平均分佈的空間量。
TextFormat
  rightMargin : Object
段落的右方邊界,以像素為單位。
TextFormat
  size : Object
這個文字格式的文字像素大小。
TextFormat
  tabStops : Array
指定自訂定位停駐點為非負值整數的陣列。
TextFormat
  target : String
指出顯示超連結的目標視窗。
TextFormat
  underline : Object
指出使用此文字格式的文字有加底線 (true) 或未加底線 (false)。
TextFormat
  url : String
指出此文字格式中之文字的目標 URL。
TextFormat
公用方法
 方法定義自
  
TextFormat(font:String = null, size:Object = null, color:Object = null, bold:Object = null, italic:Object = null, underline:Object = null, url:String = null, target:String = null, align:String = null, leftMargin:Object = null, rightMargin:Object = null, indent:Object = null, leading:Object = null)
建立含有指定屬性的 TextFormat 物件。
TextFormat
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
屬性詳細資訊

align

屬性
align:String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出段落的對齊方式。 有效的值為 TextFormatAlign 常數。

預設值為 TextFormatAlign.LEFT。



實作
    public function get align():String
    public function set align(value:String):void

擲回值
ArgumentError — 指定的 align 不是 flash.text.TextFormatAlign 的成員。

相關 API 元素


範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

blockIndent

屬性 
blockIndent:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出區塊縮排,以像素為單位。 區塊縮排會套用到文字的整個區塊;也就是文字中的所有行。 相較之下,一般縮排 (TextFormat.indent) 只會影響每個段落的第一行。 如果這個屬性為 null,TextFormat 物件就不會指定區塊縮排 (區塊縮排為 0)。



實作
    public function get blockIndent():Object
    public function set blockIndent(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

bold

屬性 
bold:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

會指定文字是否為粗體。 預設值為 null,表示不使用粗體。 如果值為 true,則文字為粗體。



實作
    public function get bold():Object
    public function set bold(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

bullet

屬性 
bullet:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出文字是項目清單的一部分。 在項目清單中,文字的每個段落都是縮排的。 在每個段落第一行的左邊,會顯示一個項目符號。 預設值為 null,表示不使用項目清單。



實作
    public function get bullet():Object
    public function set bullet(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

color

屬性 
color:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出文字的顏色。 包含三個 8 位元 RGB 組件的數字;例如 0xFF0000 是紅色,而 0x00FF00 是綠色。 預設值為 null,表示 Flash Player 使用黑色 (0x000000)。



實作
    public function get color():Object
    public function set color(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

font

屬性 
font:String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

這個文字格式的文字字體名稱,以字串表示。 預設值為 null,表示 Flash Player 對文字使用 Times New Roman 字體。



實作
    public function get font():String
    public function set font(value:String):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

indent

屬性 
indent:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出段落中從左方邊界到第一個字元的縮排。 預設值為 null,表示不使用縮排。



實作
    public function get indent():Object
    public function set indent(value:Object):void

相關 API 元素


範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

italic

屬性 
italic:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出在此文字格式中的文字是否為斜體。 預設值為 null,表示不使用斜體。



實作
    public function get italic():Object
    public function set italic(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

kerning

屬性 
kerning:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

Boolean 值,指出啟用 (true) 或停用 (false) 字距微調。 字距微調會調整特定字元對之間的像素,以改善可讀性。您應該僅在必要時 (如處理大型字體的標題) 使用此功能。 只有嵌入字體會支援字距微調。

一些字體如 Verdana 和固定間距字體 (如 Courier New),也不支援字距微調。

預設值為 null,表示不啟用字距微調。



實作
    public function get kerning():Object
    public function set kerning(value:Object):void

leading

屬性 
leading:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

整數,表示行與行之間垂直空間的量 (稱為「行距」)。 預設值為 null,指出使用的行距量為 0。



實作
    public function get leading():Object
    public function set leading(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

leftMargin

屬性 
leftMargin:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

段落的左方邊界,以像素為單位。 預設值為 null,指出左方邊界為 0 像素。



實作
    public function get leftMargin():Object
    public function set leftMargin(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

letterSpacing

屬性 
letterSpacing:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9.

數字,代表在所有字元之間平均分佈的空間量。 此值會指定增加在每個字元後的像素數。 預設值是 null,表示字元間距使用 0 個像素。 您可以使用十進位值,例如 1.75



實作
    public function get letterSpacing():Object
    public function set letterSpacing(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

rightMargin

屬性 
rightMargin:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

段落的右方邊界,以像素為單位。 預設值為 null,指出右方邊界為 0 像素。



實作
    public function get rightMargin():Object
    public function set rightMargin(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

size

屬性 
size:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

這個文字格式的文字像素大小。預設值為 null,表示使用的大小為 12。



實作
    public function get size():Object
    public function set size(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

tabStops

屬性 
tabStops:Array

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指定自訂定位停駐點為非負值整數的陣列。 每個定位停駐點都是以像素指定。 如果未指定自訂定位停駐點 (null),預設的定位停駐點就是 4 (平均字元寬度)。



實作
    public function get tabStops():Array
    public function set tabStops(value:Array):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

target

屬性 
target:String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出顯示超連結的目標視窗。 如果目標視窗是空字串,文字將顯示在預設目標視窗 _self 中。 您可以選擇一個自訂名稱或是下列四個名稱之一:_self 會指定目前視窗中的目前頁框;_blank 會指定新的視窗;_parent 會指定目前頁框的父輩;_top 會指定目前視窗中最上層的頁框。 如果 TextFormat.url 屬性為空字串或是 null,則您雖可以擷取或設定這個屬性,但該屬性不會發生作用。



實作
    public function get target():String
    public function set target(value:String):void

相關 API 元素


範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

underline

屬性 
underline:Object

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出使用此文字格式的文字有加底線 (true) 或未加底線 (false)。 這個底線和以 <U> 標籤產生的底線相似,但後者並不是真正的底線,因為它不會正確地略過超過底線的字母。 預設值為 null,表示不使用底線。



實作
    public function get underline():Object
    public function set underline(value:Object):void

範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。

url

屬性 
url:String

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

指出此文字格式中之文字的目標 URL。 如果 url 屬性是空字串,該文字就沒有超連結。 預設值為 null,指出文字沒有超連結。

注意: 具有指派之文字格式的文字,必須以 htmlText 屬性設定,才能讓超連結產生作用。



實作
    public function get url():String
    public function set url(value:String):void

相關 API 元素


範例
如何使用本範例
如需有關如何使用這個屬性的說明,請參閱 TextFormat() 建構函式的範例。
建構函式詳細資料

TextFormat

()建構函式
public function TextFormat(font:String = null, size:Object = null, color:Object = null, bold:Object = null, italic:Object = null, underline:Object = null, url:String = null, target:String = null, align:String = null, leftMargin:Object = null, rightMargin:Object = null, indent:Object = null, leading:Object = null)

語言版本: ActionScript 3.0
執行階段版本: AIR 1.0, Flash Player 9., Flash Lite 4

建立含有指定屬性的 TextFormat 物件。 然後,您就可以更改 TextFormat 物件的屬性,藉以更改文字欄位的格式。

任何參數都可以設定為 null,以指出該參數尚未定義。 所有參數都是選擇性的;任何省略的參數都會被視為 null

參數
font:String (default = null) — 文字的字體名稱,以字串表示。
 
size:Object (default = null) — 指示像素大小的整數。
 
color:Object (default = null) — 使用此文字格式的文字顏色。 包含三個 8 位元 RGB 組件的數字;例如 0xFF0000 是紅色,而 0x00FF00 是綠色。
 
bold:Object (default = null) — 指出文字是否為粗體的 Boolean 值。
 
italic:Object (default = null) — 指出文字是否為斜體的 Boolean 值。
 
underline:Object (default = null) — 指出文字是否有加底線的 Boolean 值。
 
url:String (default = null) — 此文字格式的文字所超連結至的 URL。 如果 url 是空字串,該文字就沒有超連結。
 
target:String (default = null) — 顯示超連結的目標視窗。 如果目標視窗是空字串,文字將顯示在預設目標視窗 _self 中。 如果將 url 參數設定為空字串或是 null 值,則您雖然可以擷取或設定這個屬性,但該屬性將不會發生作用。
 
align:String (default = null) — 段落的對齊方式,以 TextFormatAlign 值表示。
 
leftMargin:Object (default = null) — 指出段落的左方邊界,以像素為單位。
 
rightMargin:Object (default = null) — 指出段落的右方邊界,以像素為單位。
 
indent:Object (default = null) — 指出段落中從左方邊界到第一個字元的縮排之整數。
 
leading:Object (default = null) — 數字,指出行與行之間的開頭垂直空間量。

範例  ( 如何使用本範例 )

在下列範例中,使用者可以從清單中選取不同的文字格式選項,套用到另一個文字欄位的內容。如果使用者按一下文字欄位的內容,格式設定會回復成預設 (原始) 格式。

formatTextField 文字欄位會在另一行列出所有的 TextField 類別屬性選項 (但 kerning 例外)。 當使用者按一下 formatTextField 文字欄位中的某一行時,會觸發 formatTextFieldClickHandler() 方法。

formatTextFieldClickHandler() 方法會呼叫 TextField.getLineIndexAtPoint() 方法以取得按一下那一行的索引,然後呼叫 TextField.getLineText() 方法取得該行的內容。 接著,switch 陳述式會檢查行的內容,並據此設定 newformat TextFormat 物件的屬性。接著 setTextFormat() 方法會將 contentTextField 文字欄位的文字格式設定為新格式。 使用者可以按一下不同的 formatTextField 行,將不同的格式套用到 contentTextField 文字欄位 (tab 設定是一個陣列,定義了行中每個 tab 各自的定位停駐點)。如果選取了 urltarget 行,使用者必須按一下 contentTextField 文字欄位才能啟用連結,讓目標 URL (Flex 首頁) 的內容顯示出來。target 屬性的預設值是 "_self",表示如果使用者選取 url 行,內容將顯示在目前視窗中。為了讓 target 屬性產生作用,必須先行為 url 屬性設定一個 URL。

如果使用者按一下 contentTextField 文字欄位,則會觸發 contentTextFieldClickHandler() 方法,將此欄位的格式和 newFormat TextFormat 物件設定為文字欄位的預設 (原始) 格式。這會清除使用者已進行的所有格式變更。

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFieldAutoSize;
    import flash.events.MouseEvent;
    import flash.text.TextFormatAlign;
    
    public class TextFormat_constructorExample extends Sprite {
        private var contentTextField:TextField = new TextField();
        private var formatTextField:TextField = new TextField();
        private var newFormat:TextFormat = new TextFormat();
        
        public function TextFormat_constructorExample() {
            contentTextField.x = 10;
            contentTextField.y = 10;
            contentTextField.background = true;
            contentTextField.border = true;
            contentTextField.multiline = true;
            contentTextField.wordWrap = true;
            contentTextField.selectable = false;
            contentTextField.width = 250;
            contentTextField.height = 120; 
  
            contentTextField.htmlText = "<p>The TextFormat class represents character formatting "
                + "information. Use the TextFormat class to create specific text formatting "
                + "for text fields." + 
                " </p><br>" + "\tTab One" + "\tTab Two<br>";
              
            formatTextField.x = 10;
            formatTextField.y = 140;
            formatTextField.background = true;
            formatTextField.border = true;
            formatTextField.autoSize = TextFieldAutoSize.LEFT;
            
            formatTextField.text = "align: right\n" + "blockIndent: 10 pixels\n" + "bold:\n" + "bullet:\n" + "color: red\n"
                                + "font: Arial\n" + "indent: 20 pixels\n" + "italic:\n" + "leading: 5 spaces\n" 
                                + "leftMargin: 20 pixels\n" + "letterSpacing: 4 pixels\n" + "rightMargin: 20 pixels\n" 
                                + "size: 16 point\n" + "target: new window\n" + "tabStops: 50 and 150 pixel\n" 
                                + "underline:\n" + "url: Adobe Flex page\n";

            formatTextField.addEventListener(MouseEvent.CLICK, formatTextFieldClickHandler);
            
            contentTextField.addEventListener(MouseEvent.CLICK, contentTextFieldClickHandler);
            
            this.addChild(contentTextField);
            this.addChild(formatTextField);
        }

        private function formatTextFieldClickHandler(e:MouseEvent):void {
                var value:String= "";
                var i:uint = 0;
                var index:int = formatTextField.getLineIndexAtPoint(e.localX, e.localY);
                var line:String = formatTextField.getLineText(index);;

                line = line.substr(0, (line.indexOf(":")));

                switch(line) {
                    case "align":
                        newFormat.align = TextFormatAlign.RIGHT;
                        break;
                    case "blockIndent":
                        newFormat.blockIndent = 10;
                        break;
                    case "bold":
                        newFormat.bold = true;
                        break;
                    case "bullet":
                        newFormat.bullet = true;
                        break;
                    case "color":
                        newFormat.color = 0xFF0000;        
                        break;
                    case "font":
                        newFormat.font = "Arial";
                        break;
                    case "indent":
                        newFormat.indent = 20;
                        break;
                    case "italic":
                        newFormat.italic = true;
                        break;
                    case "leading":
                        newFormat.leading = 5;
                        break;
                    case "leftMargin":
                        newFormat.leftMargin = 20;
                        break;
                    case "letterSpacing":
                        newFormat.letterSpacing = 4;
                        break;
                    case "rightMargin":
                        newFormat.rightMargin = 20;
                        break;
                    case "size":
                        newFormat.size = 16;
                        break;
                    case "tabStops":                
                        newFormat.tabStops = [50, 150];
                        break;
                    case "target":
                        newFormat.url = "http://www.adobe.com/products/flex/";    
                        newFormat.target = "_blank";
                        break;    
                    case "underline":
                        newFormat.underline = true;
                        break;
                    case "url":
                        newFormat.url = "http://www.adobe.com/products/flex/";    
                        break;
                }    

                contentTextField.setTextFormat(newFormat);
        }

        private function contentTextFieldClickHandler(e:MouseEvent):void {
            contentTextField.setTextFormat(contentTextField.defaultTextFormat);
            newFormat = contentTextField.defaultTextFormat;
        }
    }
}
TextFormatExample.as

下列範例會建立 TextFieldExample 類別,在其預設位置 (x = 0, y = 0) 顯示文字訊息。 這是透過下列步驟完成:
  1. 建立類型為 TextField 的 label 屬性。
  2. 類別建構函式會呼叫函數 configureLabel()
  3. configureLabel() 函數會先建立新的 TextField 物件並將它指定給 label,然後將它的參數設定為下列各項
    • 使文字欄位左側對齊
    • 啟用背景填色
    • 啟用邊框。
  4. 接著,configureLabel() 會建立區域變數 format,並將此變數指定給新的 TextFormat 實體,其參數設定為下列各項:
    • Font type = Verdana
    • Font Color = solid red
    • Font size = 10
    • Font underline = true。
  5. 標籤的 defaultTextFormat 屬性已經設定為 formatlabel 實體也已經加入顯示清單,舞台上就會開始顯示一個不含文字的文字欄位 (具有白色背景的極小方塊)。
  6. 最後 (回到建構函式中),呼叫 setLabel() 設定標籤的文字,在 x = 0、y = 0 座標上顯示 "Hello World and welcome to the show"。
 package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;


    public class TextFormatExample extends Sprite {
        private var label:TextField;

        public function TextFormatExample() {
            configureLabel();
            setLabel("Hello World and welcome to the show");
        }

        public function setLabel(str:String):void {
            label.text = str;
        }

        private function configureLabel():void {
            label = new TextField();
            label.autoSize = TextFieldAutoSize.LEFT;
            label.background = true;
            label.border = true;

            var format:TextFormat = new TextFormat();
            format.font = "Verdana";
            format.color = 0xFF0000;
            format.size = 10;
            format.underline = true;

            label.defaultTextFormat = format;
            addChild(label);
        }
    }
}




[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。