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

顶级 

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 示例
法律声明

顶级函数或全局函数在使用 ActionScript 的 SWF 文件的任何部分或任何用户定义类中都可用。已将 ActionScript 2.0 中的大部分全局函数迁移到类中。
全局函数
 函数由以下参数定义
  
创建一个新数组。
顶级
  
Boolean(expression:Object):Boolean
将 expression 参数转换为布尔值并返回该值。
顶级
  
将已编码的 URI 解码为字符串。
顶级
  
将已编码的 URI 组件解码为字符串。
顶级
  
将字符串编码为有效的 URI(统一资源标识符)。
顶级
  
将字符串编码为有效的 URI 组件。
顶级
  
将参数转换为字符串,并以 URL 编码格式对其进行编码,在这种格式中,大多数非字母数字的字符都替换为 % 十六进制序列。
顶级
  
int(value:Number):int
将给定数字值转换成整数值。
顶级
  
如果该值为有限数,则返回 true,如果该值为正无穷大或负无穷大,则返回 false。
顶级
  
如果该值为 NaN(非数字),则返回 true。
顶级
  
确定指定字符串对于 XML 元素或属性是否为有效名称。
顶级
  
Number(expression:Object):Number
将给定值转换成数字值。
顶级
  
在 ActionScript 3.0 中,每个值都是一个对象,这意味着对某个值调用 Object() 会返回该值。
顶级
  
将字符串转换为浮点数。
顶级
  
parseInt(str:String, radix:uint = 0):Number
将字符串转换为整数。
顶级
  
String(expression:Object):String
返回指定参数的字符串表示形式。
顶级
  
trace(... arguments):void
调试时显示表达式或写入日志文件。
顶级
  
将给定数字值转换成无符号整数值。
顶级
  
将参数 str 作为字符串计算,从 URL 编码格式解码该字符串(将所有十六进制序列转换成 ASCII 字符),并返回该字符串。
顶级
  
Vector(sourceArray:Object):Vector.<T>
创建新的 Vector 实例,其元素为指定数据类型的实例。
顶级
  
XML(expression:Object):XML
将对象转换成 XML 对象。
顶级
  
XMLList(expression:Object):XMLList
将某对象转换成 XMLList 对象。
顶级


顶级常量或全局常量在每个脚本中都可用,并且对文档中的所有时间轴和作用域都可见。
全局常量
 常量由以下参数定义
  Infinity : Number
表示正无穷大的特殊值。
顶级
  -Infinity : Number
表示负无穷大的特殊值。
顶级
  NaN : Number
Number 数据类型的一个特殊成员,用来表示“非数字”(NaN) 值。
顶级
  undefined : *
一个适用于尚未初始化的无类型变量或未初始化的动态对象属性的特殊值。
顶级
常量详细信息

-Infinity

常量
public const -Infinity:Number

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

表示负 Infinity 的特殊值。此常量的值与 Number.NEGATIVE_INFINITY 相同。

相关 API 元素


示例  ( 如何使用本示例 )

除以 0 的结果为 -Infinity(仅当除数为负数时)。
trace(0 / 0);  // NaN
trace(7 / 0);  // Infinity
trace(-7 / 0); // -Infinity


Infinity

常量 
public const Infinity:Number

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

表示正 Infinity 的特殊值。此常量的值与 Number.POSITIVE_INFINITY 相同。

相关 API 元素


示例  ( 如何使用本示例 )

除以 0 的结果为 Infinity(仅当除数为正数时)。
trace(0 / 0);  // NaN
trace(7 / 0);  // Infinity
trace(-7 / 0); // -Infinity


NaN

常量 
public const NaN:Number

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

Number 数据类型的一个特殊成员,用来表示“非数字”(NaN) 值。当数学表达式生成的值无法表示为数字时,结果为 NaN。下表描述了生成 NaN 的常用表达式。

  • 除以 0 可生成 NaN(仅当除数也为 0 时)。如果除数大于 0,除以 0 的结果为 Infinity。如果除数小于 0,除以 0 的结果为 -Infinity
  • 负数的平方根;
  • 在有效范围 0 到 1 之外的数字的反正弦值;
  • Infinity 减去 Infinity
  • Infinity-Infinity 除以 Infinity-Infinity
  • Infinity-Infinity 乘以 0;

NaN 值不是 int 或 uint 数据类型的成员。

NaN 值不被视为等于任何其他值(包括 NaN),因而无法使用等于运算符测试一个表达式是否为 NaN。要确定一个数字是否为 NaN 函数,请使用 isNaN()

相关 API 元素

undefined

常量 
public const undefined:*

语言版本: ActionScript 3.0
运行时版本: AIR 1.0, Flash Player 9

一个适用于尚未初始化的无类型变量或未初始化的动态对象属性的特殊值。在 ActionScript 3.0 中,只有无类型变量才能采用值 undefined,这在 ActionScript 1.0 和 ActionScript 2.0 中并非如此。例如,以下两个变量都是 undefined,因为它们都未类型化或初始化:

  • var foo;
  • var bar:*;

undefined 值还适用于动态对象的未初始化或未定义的属性。例如,如果某对象是 Object 类的一个实例,则除非向该属性赋予值,否则动态添加的任何属性的值将为 undefined

undefined 用于不同的函数时,结果也不相同:

  • String(undefined) 返回的值为 "undefined"undefined 转换为字符串)。
  • Number(undefined) 返回的值为 NaN
  • int(undefined)uint(undefined) 返回的值为 0。
  • Object(undefined) 返回的值为新的 Object 实例。
  • 向类型变量赋予值 undefined 时,该值将转换为该数据类型的默认值。

不要混淆 undefinednull。使用等于运算符 (==) 对 nullundefined 进行比较时,它们的比较结果为相等。但是,使用 strict equality (===) 运算符对 nullundefined 进行比较时,它们的比较结果为不相等。

相关 API 元素


示例  ( 如何使用本示例 )

在以下示例中,将声明(但不初始化)一个无类型变量 myVarmyVar 的值为 undefined,因为该变量是一个无类型变量。无论变量是没有类型注释,还是使用特殊的 (*) 无类型注释 (var myVar:*;),都是如此。
// trace value of untyped and uninitialized variable
var myVar;
trace(myVar); // undefined

该规则同样适用于动态对象的未初始化属性。例如,给定实例 obj(属于动态类 A),obj.propNameobj 实例的未初始化属性)的值为 undefined
dynamic class A {}
var obj:A = new A()

// trace undefined property of obj
trace(obj.propName); // undefined

函数详细信息

Array

()函数
public function Array(... args):Array

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

创建一个新数组。数组可以是零长度或更大长度,或者是由一个指定的对象填充的数组。

  • 在不使用参数的情况下调用 Array() 会返回空的数组。
  • 使用单个整数参数调用 Array() 可返回具有指定长度的数组,但数组元素具有未定义的值。
  • 调用具有指定对象的 Array() 将返回一个具有该指定对象的元素的数组。
使用 Array() 函数类似于使用 Array 类构造函数创建一个数组,但是 Array() 函数只允许一个参数值或根本不允许参数值。您无法使用 Array() 函数用多个值填充新数组。

注意:如果您尝试使用 Array() 函数创建一个新数组,并将多个值作为参数传递以填充该数组,将出现编译器错误。Array() 函数只允许一个参数。相反,应使用 Array 类构造函数创建和填充一个多值数组。

Array() 函数不将对象的类型转换为数组。当参数不是原始值时,应使用 as 运算符进行显式类型转换或类型转换。有关详细信息,请参阅本条目的“示例”部分。如果您将对象作为参数传递给 Array() 函数,会创建一个新数组,其中包含此对象作为元素。

参数

... args — 您可以对空数组不传递参数、对特定长度的数组传递一个整数参数,或者传递一个对象以创建包含一个指定对象的数组。

返回
Array — 长度为 0 或大于 0 的数组。

相关 API 元素


示例  ( 如何使用本示例 )

下面的示例演示 Array() 函数在参数不是原始值时的行为。转换为数组的一种常见用法是转换以数组格式存储值的 Object 实例。如果调用 Array() 时使用了 Object 类型或其他任何非基元数据类型的参数,则对对象的引用将存储在新数组的元素中。也就是说,如果传递的唯一参数是一个对象,则对该对象的引用将成为新数组的第一个元素。
var obj:Object = [ "a", "b", "c" ];
      
var newArray:Array = Array( obj );

trace(newArray == obj);    // false
trace(newArray[0] == obj); // true
trace(newArray[0][0])      // a
trace(newArray[0][1])      // b
trace(newArray[0][2])      // c

要将 obj 转换为数组,请使用 as 运算符,它将在 obj 为有效数组的情况下返回数组引用,否则返回 null
var obj:Object = [ "a", "b", "c" ];
      
var newArray:Array = obj as Array;

trace(newArray == obj); // true
trace(newArray[0]);     // a
trace(newArray[1]);     // b
trace(newArray[2]);     // c

Boolean

()函数 
public function Boolean(expression:Object):Boolean

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

expression 参数转换为布尔值并返回该值。

返回值取决于参数的数据类型和值,如下表所述:

输入值示例返回值
0Boolean(0)false
NaNBoolean(NaN)false
数字(非 0NaNBoolean(4)true
空字符串Boolean("")false
非空字符串Boolean("6")true
nullBoolean(null)false
undefinedBoolean(undefined)false
Object 类的实例Boolean(new Object())true
无参数Boolean()false

与 ActionScript 的早期版本不同,Boolean() 函数与 Boolean 类构造函数返回相同的结果。

参数

expression:Object — 要转换为 Boolean 的表达式或对象。

返回
Boolean — 转换为 Boolean 的结果。

decodeURI

()函数 
public function decodeURI(uri:String):String

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

将已编码的 URI 解码为字符串。返回一个字符串,其中以前由 encodeURI 函数编码的所有字符都还原为它们的未编码表示形式。

下表显示不会decodeURI 函数解码为字符的转义序列的集合。使用 decodeURIComponent() 可解码此表中的转义序列。

未解码的转义序列字符等效形式
%23#
%24$
%26&
%2B+
%2C,
%2F/
%3A:
%3B;
%3D=
%3F?
%40@

参数

uri:String — 一个使用 encodeURI 函数编码的字符串。

返回
String — 一个字符串,其中以前由 encodeURI 函数转义的所有字符都还原为它们的未转义表示形式。

相关 API 元素


示例  ( 如何使用本示例 )

package {
    import flash.display.Sprite;

    public class DecodeURIExample extends Sprite {
        public function DecodeURIExample() {
            var uri:String = "http://www.example.com/application.jsp?user=<user name='some user'></user>";
            var encoded:String = encodeURI(uri);
            var decoded:String = decodeURI(encoded);
            trace(uri);        // http://www.example.com/application.jsp?user=<user name='some user'></user>
            trace(encoded);    // http://www.example.com/application.jsp?user=%3Cuser%20name='some%20user'%3E%3C/user%3E
            trace(decoded);    // http://www.example.com/application.jsp?user=<user name='some user'></user>
        }
    }
}

decodeURIComponent

()函数 
public function decodeURIComponent(uri:String):String

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

将已编码的 URI 组件解码为字符串。返回一个字符串,其中以前由 encodeURIComponent 函数转义的所有字符都还原为它们的未编码表示形式。

此函数与 decodeURI() 函数不同,它仅适用于 URI 字符串的一部分(称为 URI 组件)。URI 组件是指出现在某些特殊字符之间的任何文本,这些特殊字符称为组件分隔符: / ; 和 ?)。“http”和“www.adobe.com”是常见的 URI 组件示例。

此函数与 decodeURI() 的另一个重要区别是:由于此函数假定它处理的是 URI 组件,因此它会将表示特殊分隔符字符 (; / ? : @ & = + $ , #) 的转义序列视为应进行解码的常规文本。

参数

uri:String — 一个使用 encodeURIComponent 函数编码的字符串。

返回
String — 一个字符串,其中以前由 encodeURIComponent 函数转义的所有字符都还原为它们的未转义表示形式。

相关 API 元素

encodeURI

()函数 
public function encodeURI(uri:String):String

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

将字符串编码为有效的 URI(统一资源标识符)。将完整的 URI 转换为一个字符串,其中除属于一小组基本字符的字符外,其他所有字符都以 UTF-8 转义序列进行编码。

下表显示不会encodeURI 函数转换为 UTF-8 转义序列的基本字符的整个集合。

未编码的字符
0 1 2 3 4 5 6 7 8 9
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
; / ? : @ & = + $ , #
- _ . ! ~ * ' ( )

参数

uri:String — 一个表示完整 URI 的字符串。

返回
String — 一个字符串,其中某些字符已编码为 UTF-8 转义序列。

相关 API 元素


示例  ( 如何使用本示例 )

package {
    import flash.display.Sprite;

    public class EncodeURIExample extends Sprite {
        public function EncodeURIExample() {
            var uri:String = "http://www.example.com/application.jsp?user=<user name='some user'></user>";
            var encoded:String = encodeURI(uri);
            var decoded:String = decodeURI(encoded);
            trace(uri);        // http://www.example.com/application.jsp?user=<user name='some user'></user>
            trace(encoded);    // http://www.example.com/application.jsp?user=%3Cuser%20name='some%20user'%3E%3C/user%3E
            trace(decoded);    // http://www.example.com/application.jsp?user=<user name='some user'></user>
        }
    }
}

encodeURIComponent

()函数 
public function encodeURIComponent(uri:String):String

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

将字符串编码为有效的 URI 组件。将 URI 的子字符串转换为一个字符串,其中除属于非常小的一组基本字符的字符外,其他所有字符都以 UTF-8 转义序列进行编码。

encodeURIComponent() 函数与 encodeURI() 函数不同,它仅适用于 URI 字符串的一部分(称为 URI 组件)。URI 组件是指出现在某些特殊字符之间的任何文本,这些特殊字符称为组件分隔符: / ; 和 ?)。“http”和“www.adobe.com”是常见的 URI 组件示例。

此函数与 encodeURI() 的另一个重要区别是:由于此函数假定它处理的是 URI 组件,因此它会将特殊分隔符字符 (; / ? : @ & = + $ , #) 视为应进行编码的常规文本。

下表显示不会encodeURIComponent 函数转换为 UTF-8 转义序列的所有字符。

未编码的字符
0 1 2 3 4 5 6 7 8 9
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
- _ . ! ~ * ' ( )

参数

uri:String

返回
String

相关 API 元素

escape

()函数 
public function escape(str:String):String

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

将参数转换为字符串,并以 URL 编码格式对其进行编码,在这种格式中,大多数非字母数字的字符都替换为 % 十六进制序列。当用于 URL 编码的字符串时,百分号 (%) 用于引入转义字符,不与模运算符 (%) 等效。

下表显示不会escape() 函数转换为转义序列的所有字符。

未编码的字符
0 1 2 3 4 5 6 7 8 9
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
@ - _ . * + /

注意:请使用 encodeURIComponent() 函数(而不是 escape() 函数)将特殊分隔符 (@ + /) 做为常规文本进行编码。

参数

str:String — 要转换为字符串并以 URL 编码格式进行编码的表达式。

返回
String — 一个 URL 编码的字符串。

相关 API 元素

int

()函数 
public function int(value:Number):int

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

将给定数字值转换成整数值。从小数点处截断十进制值。

参数

value:Number — 要转换成整数的值。

返回
int — 转换后的整数值。

相关 API 元素

isFinite

()函数 
public function isFinite(num:Number):Boolean

语言版本: ActionScript 3.0.
运行时版本: AIR 1.0, Flash Player 9, Flash Lite 4

如果该值为有限数,则返回 true,如果该值为 Infinity-Infinity,则返回 false。出现的 Infinity-Infinity 表示存在错误的数学条件,例如除以 0。

参数

num:Number — 要计算为有限数或无穷大的数字。

返回
Boolean — 若结果为一个有限数,则返回 true;若结果为无穷大或负无穷大,则返回 false

isNaN

()函数 
public function isNaN(num:Number):Boolean

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

如果该值为 NaN(非数字),则返回 trueisNaN() 函数可用于检查一个数学表达式是否成功地计算为一个数字。isNaN() 最常用于检查从 parseInt()parseFloat() 函数返回的值。NaN 值是 Number 数据类型的特殊成员,用来表示“非数字”值。

注意NaN 值不是 int 或 uint 数据类型的成员。

下表描述 isNaN() 针对各种输入类型和值的返回值。(如果编译器警告设置为“严谨模式”,则下面的某些操作将生成编译器警告。)

输入类型/值示例返回值
0 除以 0isNaN(0/0)true
非零数字除以 0isNaN(5/0)false
负数的平方根isNaN(Math.sqrt(-1))true
大于 1 或小于 0 的数字的反正弦值isNaN(Math.asin(2))true
可以转换为 Number 的字符串isNaN("5")false
无法转换为 Number 的字符串isNaN("5a")true

参数

num:Number — 要计算的数值或数学表达式。

返回
Boolean — 如果该值为 NaN(非数字),则返回 true;否则返回 false

isXMLName

()函数 
public function isXMLName(str:String):Boolean

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

确定指定字符串对于 XML 元素或属性是否为有效名称。

参数

str:String — 要计算的字符串。

返回
Boolean — 如果 str 参数为有效的 XML 名称,则返回 true;否则返回 false

Number

()函数 
public function Number(expression:Object):Number

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

将给定值转换成数字值。下表显示各种输入类型的结果:

输入类型/值示例返回值
undefinedNumber(undefined)NaN
nullNumber(null)0
trueNumber(true)1
falseNumber(false)0
NaNNumber(NaN)NaN
空字符串Number("")0
转换为数字的字符串Number("5")数字(例如 5
没有转换为数字的字符串Number("5a")NaN

参数

expression:Object — 要转换为数字的值。

返回
Number — 转换后的数值

Object

()函数 
public function Object(value:Object):Object

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

在 ActionScript 3.0 中,每个值都是一个对象,这意味着对某个值调用 Object() 会返回该值。

参数

value:Object — 要转换的对象、数字、字符串或布尔值。

返回
Object — 由 value 参数指定的值。

parseFloat

()函数 
public function parseFloat(str:String):Number

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

将字符串转换为浮点数。此函数读取或分析 并返回字符串中的数字,直到此函数遇到不是初始数字一部分的字符。如果字符串不是以可以分析的数字开头,parseFloat() 将返回 NaN。有效整数前面的空白将被忽略,有效整数后面的非数字字符也将被忽略。

参数

str:String — 要读取并转换为浮点数的字符串。

返回
Number — 一个数字或 NaN(非数字)。

parseInt

()函数 
public function parseInt(str:String, radix:uint = 0):Number

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

将字符串转换为整数。如果参数中指定的字符串不能转换为数字,则此函数返回 NaN。以 0x 开头的字符串被解释为十六进制数字。与 ActionScript 的早期版本不同,以 0 开头的整数不会被解释为八进制数字。必须指定 8 的基数才能解释为八进制数字。有效整数前面的空白和 0 以及后面的非数字字符将被忽略。

参数

str:String — 要转换为整数的字符串。
 
radix:uint (default = 0) — 表示要分析的数字的基数(基)的整数。合法值为 2 到 36。

返回
Number — 一个数字或 NaN(非数字)。

String

()函数 
public function String(expression:Object):String

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

返回指定参数的字符串表示形式。

下表显示各种输入类型的结果:

输入类型/值返回值
undefinedundefined
null"null"
true"true"
false"false"
NaN"NaN"
字符串字符串
objectObject.toString()
Number数字的字符串表示形式

参数

expression:Object — 要转换为字符串的表达式。

返回
String — 为 expression 参数传递的值的字符串表示形式。

trace

()函数 
public function trace(... arguments):void

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

调试时显示表达式或写入日志文件。单个跟踪语句可支持多个参数。如果跟踪语句中的任何参数包含 String 之外的数据类型,则跟踪函数将调用与该数据类型关联的 toString() 方法。例如,如果该参数是一个布尔值,则跟踪函数将调用 Boolean.toString() 并显示返回值。

参数

... arguments — 要计算的一个或多个(逗号分隔)表达式。对于多个表达式,输出中每个表达式之间都将插入一个空格。


示例  ( 如何使用本示例 )

下面的示例使用类 TraceExample 来演示如何使用 trace() 方法输出简单字符串。通常情况下,消息将输出到“调试”控制台。
package {
    import flash.display.Sprite;

    public class TraceExample extends Sprite {

        public function TraceExample() {
            trace("Hello World");
        }
    }
}

uint

()函数 
public function uint(value:Number):uint

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

将给定数字值转换成无符号整数值。从小数点处截断十进制值。

下表描述 uint() 针对各种输入类型和值的返回值。

输入类型/值示例返回值
undefineduint(undefined)0
nulluint(null)0
0uint(0)0
NaNuint(NaN)0
正浮点数uint(5.31)截断的无符号整数(例如,5
负浮点数uint(-5.78)截断为整数,然后应用负整数规则
负整数uint(-5)uint.MAX_VALUE 与负整数的和(例如,uint.MAX_VALUE + (-5)
trueuint(true)1
falseuint(false)0
空字符串uint("")0
转换为数字的字符串uint("5")数字
没有转换为数字的字符串uint("5a")0

参数

value:Number — 要转换成整数的值。

返回
uint — 转换后的整数值。

相关 API 元素

unescape

()函数 
public function unescape(str:String):String

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

将参数 str 作为字符串计算,从 URL 编码格式解码该字符串(将所有十六进制序列转换成 ASCII 字符),并返回该字符串。

参数

str:String — 要转义的十六进制序列字符串。

返回
String — 对 URL 编码的参数进行解码所得到的字符串。

Vector

()函数 
public function Vector(sourceArray:Object):Vector.<T>

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

创建新的 Vector 实例,其元素为指定数据类型的实例。在调用此函数时,可使用类型参数指定结果 Vector 元素的数据类型(Vector 的基本类型)。此函数使用的语法与声明 Vector 实例或调用 new Vector.<T>() 构造函数时所使用的语法相同:

var v:Vector.<String> = Vector.<String>(["Hello", "World"]);

sourceArray 参数的元素中的值填充结果 Vector。如果 sourceArray 参数已经是 Vector.<T> 实例(其中 T 为基本类型),则函数将返回该 Vector。否则,将用 sourceArray Array 或 Vector 的元素填充结果 Vector。

在上述任一情况下,sourceArray 参数的所有元素的数据类型都必须与函数调用中指定的基本类型 T 匹配。

如果 sourceArray 参数的 length 为 0,则此函数将返回一个空白 Vector。

如果 Vector 作为 sourceArray 参数传递且其基本类型不是 T,或者如果传递一个 Array 且其元素并不全是数据类型 T 的实例,则会尝试将值转换为基本类型。如果这些值可以自动转换,则结果 Vector 中会包含转换后的值。如果无法进行任何转换,则会出现一个错误。

同样,如果 sourceArray 参数中的某个元素是基本类型 T 的子类的实例,则调用成功,并且该元素将添加到结果 Vector 中。即使 sourceArray 参数是一个 Vector 并且其基本类型是 T 的子类,也会出现上述情况。实际上,只有通过这种方法才能将基本类型为 T 的 Vector 转换为基本类型为 T 的子类的 Vector。

例如,由于以下代码尝试将 Vector.<Sprite> 分配给 Vector,因此该代码在严谨模式下会导致出现编译错误或在运行时导致出现 TypeError。<DisplayObject> 变量(Sprite 是 DisplayObject 的子类):

     var v1:Vector.<Sprite> = new Vector.<Sprite>();
     v1[0] = new Sprite();
     var v2:Vector.<DisplayObject> = v1;
     

以下替代版本的代码可成功地将 Vector.<Sprite> 实例的元素复制到 Vector.<DisplayObject> 实例中:

     var v1:Vector.<Sprite> = new Vector.<Sprite>();
     v1[0] = new Sprite();
     var v2:Vector.<DisplayObject> = Vector.<DisplayObject>(v1);
     

参数

sourceArray:Object — 一个 Array 或 Vector 实例,其元素会成为结果 Vector 的元素。如果参数是一个 Vector 实例并且其关联数据类型与指定的数据类型相同,则该参数作为函数结果返回。

返回
Vector.<T> — 一个用 sourceArray 数组的元素来填充的 Vector 实例。

引发
TypeError — 如果 sourceArray 参数包含无法转换为指定数据类型的元素。

相关 API 元素

XML

()函数 
public function XML(expression:Object):XML

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

将对象转换成 XML 对象。

下表介绍各种输入类型的返回值。

参数类型返回值
Boolean首先将值转换成一个字符串,然后转换成一个 XML 对象。
Null发生运行时错误(TypeError 异常)。
Number首先将值转换成一个字符串,然后转换成一个 XML 对象。
object仅当值为字符串值、数值或布尔值时才转换为 XML。否则会发生运行时错误(TypeError 异常)。
字符串转换为 XML 的值。
未定义发生运行时错误(TypeError 异常)。
XML返回未修改的输入值。
XMLList仅当 XMLList 对象只包含 XML 类型的某个属性时才返回 XML 对象。否则会发生运行时错误(TypeError 异常)。

参数

expression:Object — 要转换为 XML 的对象。

返回
XML — 一个 XML 对象,它包含转换后的对象中存放的值。

相关 API 元素

XMLList

()函数 
public function XMLList(expression:Object):XMLList

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

将某对象转换成 XMLList 对象。

下表介绍各种输入类型的返回值。

参数类型返回值
Boolean首先将值转换成一个字符串,然后转换成一个 XMLList 对象。
Null发生运行时错误(TypeError 异常)。
Number首先将值转换成一个字符串,然后转换成一个 XMLList 对象。
object仅当值为字符串值、数值或布尔值时才转换为 XMLList。否则会发生运行时错误(TypeError 异常)。
字符串将值转换成一个 XMLList 对象。
未定义发生运行时错误(TypeError 异常)。
XML将值转换成一个 XMLList 对象。
XMLList返回未修改的输入值。

参数

expression:Object — 要转换为 XMLList 对象的对象。

返回
XMLList — 一个 XMLList 对象,它包含转换后的对象中存放的值。

相关 API 元素

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

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