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

Collator  - 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.globalization
public final class Collator
继承Collator Inheritance Object

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

Collator 类提供区分区域设置的字符串比较功能。

此类使用操作系统提供的字符串比较服务。这些比较随创建类实例时提供的区域设置标识符的不同而不同。ActionScript 使用 Unicode 字符集存储字符串。布尔型字符串比较运算符(==、!=、<、<=、>、>=)使用 Unicode 代码点进行比较。在多数情况下,生成的排序顺序与特定语言和区域的约定不匹配,因此不应该用于对用户界面中显示的字符串进行排序。而此类中的比较方法提供了符合这些约定的顺序。

以下是一些示例,其中排序顺序随语言的不同而不同:

  • 在英语中,小写 a 在大写 A 之前,而大写 A 在小写 b 之前。
  • 在瑞典语中,ö 在 z 之后,而在德语中,ö 在 o 之后
  • 在传统西班牙语中,ch 是一个排在 c 和 d 之间的字符

甚至在同一语言和区域内,排序顺序也可以根据使用情况有所不同。例如,在德语中,电话簿中的姓名与词典中的词的排序顺序不同。在中文和日语中,表意字排序有多种方式:即按读音或按字形中使用的表意字字根和笔画数。在西班牙语和格鲁吉亚语中,现代排序和传统排序之间存在差异。

此类中的比较方法提供了两种主要使用模式。Collator() 构造函数的 initialMode 参数控制这些模式。默认“排序”模式适用于将显示给最终用户的排序项目。在此模式中,比较更为严格,以确保在其他方面相同的项目以一致的方式排序。例如,大写字母和小写字母不作为相同内容进行比较。在“匹配”模式中,比较相对宽松。例如,在此模式中大写和小写字母会被视为相同。以下是一个演示这两种模式的示例:

 
     var sortingCollator:Collator = new Collator("en-US", CollatorMode.SORTING);
     var words:Array = new  Array("Airplane" , "airplane", "boat", "Boat");
     words.sort(sortingCollator.compare);
     trace(words);
              
     var matchingCollator:Collator = new Collator("en-US", CollatorMode.MATCHING);
     if (matchingCollator.equals("Car", "car")) {
       trace("The words match!");
     }
     

即使如上所示向构造函数提供区域设置 ID 参数,排序行为也可能因用户的操作系统设置而随用户变化,还可能在请求的区域设置不受支持时,随是否使用回退区域设置而不同。

查看示例



公共属性
 属性由以下参数定义
  actualLocaleIDName : String
[只读] 此 Collator 对象使用的实际区域设置 ID 的名称。
Collator
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  ignoreCase : Boolean
当此属性设置为 true 时,完全相同的字符串和仅字母大小写不同的字符串比较结果为相等。
Collator
  ignoreCharacterWidth : Boolean
当此属性为 true 时,某些全角和半角形式的中文和日文字符比较结果为相等。
Collator
  ignoreDiacritics : Boolean
当此属性设置为 true 时,使用相同基本字符,但重音符号或其它音调符号不同的字符串,比较结果为相等。
Collator
  ignoreKanaType : Boolean
当此属性设置为 true 时,会将区别仅在于使用了不同的 kana 字符类型的字符串视为相等。
Collator
  ignoreSymbols : Boolean
当此属性设置为 true 时,排序或匹配时将忽略空格、货币符号、数学符号和其它类型符号等符号字符。
Collator
  lastOperationStatus : String
[只读] 此 Collator 对象执行的最近操作的状态。
Collator
  numericComparison : Boolean
控制如何在进行字符串比较期间处理嵌入到字符串的数值。
Collator
  requestedLocaleIDName : String
[只读] 传递到此 Collator 对象的构造函数的请求的区域设置 ID 名称。
Collator
公共方法
 方法由以下参数定义
  
Collator(requestedLocaleIDName:String, initialMode:String = "sorting")
构造新的 Collator 对象,以根据指定的区域设置的约定提供字符串比较。
Collator
  
compare(string1:String, string2:String):int
比较两个字符串并返回一个整数值,表示第一个字符串是小于、等于还是大于第二个字符串。
Collator
  
equals(string1:String, string2:String):Boolean
比较两个字符串并返回表示字符串是否相等的布尔值。
Collator
  
[静态] 列出此类支持的所有区域设置 ID 名称。
Collator
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
属性详细信息

actualLocaleIDName

属性
actualLocaleIDName:String  [只读]

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

此 Collator 对象使用的实际区域设置 ID 的名称。

根据操作系统和传递给 Collator() 构造函数的 requestedLocaleIDName 参数的值,该名称有三种可能的值。

  1. 如果请求的区域设置不是 LocaleID.DEFAULT 且操作系统支持该请求的区域设置,则返回的名称与 requestedLocaleIDName 属性相同。
  2. 如果将 LocaleID.DEFAULT 用作构造函数的 requestedLocaleIDName 参数的值,则使用由用户操作系统指定的当前区域设置的名称。LocaleID.DEFAULT 值保留用户在操作系统中的自定义设置。显式值作为 requestedLocaleIDName 参数传递与使用 LocaleID.DEFAULT 所产生的结果不一定相同,即使两个区域设置 ID 名称相同,也是如此。用户可能已在他们的计算机上对区域设置进行了自定义,通过请求显式区域设置 ID 名称(而不是使用 LocaleID.DEFAULT),您的应用程序将不会检索这些自定义设置。
  3. 如果系统不支持在构造函数中指定的 requestedLocaleIDName,则会提供回退区域设置 ID 名称。



实现
    public function get actualLocaleIDName():String

相关 API 元素

ignoreCase

属性 
ignoreCase:Boolean

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

当此属性设置为 true 时,完全相同的字符串和仅字母大小写不同的字符串比较结果为相等。例如,当 ignoreCase 属性设置为 true 时,compare("ABC", "abc") 将返回 true

字符串的大小写转换遵守指定的区域设置的规则。

ignoreCase 属性为 false 时,大小写字符不相等。

为此属性分配了值并且未引发错误或警告时,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

Collator() 构造函数的 initialMode 参数设置为 Collator.MATCHING 时,默认值为 true。当 Collator() 构造函数的 initialMode 参数设置为 Collator.SORTING 时,默认值为 false



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

相关 API 元素

ignoreCharacterWidth

属性 
ignoreCharacterWidth:Boolean

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

当此属性为 true 时,某些全角和半角形式的中文和日文字符比较结果为相等。

为与中文和日文字符集的现有标准兼容,Unicode 为某些全角和半角形式的字符提供字符代码。例如,当 ignoreCharacterWidth 属性设置为 true 时,compare("Aア", "Aア") 返回 true

如果将 ignoreCharacterWidth 属性设置为 false,则全角和半角形式的字符不相等。

为此属性分配了值并且未引发错误或警告时,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

默认值为 false。



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

相关 API 元素

ignoreDiacritics

属性 
ignoreDiacritics:Boolean

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

当此属性设置为 true 时,使用相同基本字符,但重音符号或其它音调符号不同的字符串,比较结果为相等。例如,当 ignoreDiacritics 属性设置为 true 时,compare("coté", "côte") 返回 true

ignoreDiacritics 设置为 false 时,带有音调符号或重音符号的基本字符被视为不相等。

为此属性分配了值并且未引发错误或警告时,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

默认值为 false。



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

相关 API 元素

ignoreKanaType

属性 
ignoreKanaType:Boolean

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

当此属性设置为 true 时,会将区别仅在于使用了不同的 kana 字符类型的字符串视为相等。例如,当 ignoreKanaType 属性设置为 true 时,compare("カナ", "かな") 返回 true

如果将 ignoreKanaType 设置为 false,则引用相同音节的平假名和片假名字符不相等。

为此属性分配了值并且未引发错误或警告时,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

默认值为 false。



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

相关 API 元素

ignoreSymbols

属性 
ignoreSymbols:Boolean

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

当此属性设置为 true 时,排序或匹配时将忽略空格、货币符号、数学符号和其它类型符号等符号字符。例如,当 ignoreSymbols 属性设置为 true 时,“OBrian”、“O'Brian”和“O Brian”字符串都被视为相等。

如果 ignoreSymbols 属性为 false,则字符串比较将考虑符号字符。

为此属性分配了值并且未引发错误或警告时,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

默认值为 false。



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

相关 API 元素

lastOperationStatus

属性 
lastOperationStatus:String  [只读]

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

此 Collator 对象执行的最近操作的状态。只要调用构造函数或此类的一个方法,或设置一个属性,都会设置 lastOperationStatus。有关可能值的信息,请参阅每种方法下的说明。



实现
    public function get lastOperationStatus():String

相关 API 元素

numericComparison

属性 
numericComparison:Boolean

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

控制如何在进行字符串比较期间处理嵌入到字符串的数值。

numericComparison 属性设置为 true 时,比较方法将出现在字符串中的数字转换为数值以供比较。

当此属性设置为 false 时,比较时将把数字视为字符代码,并根据指定区域设置中对字符排序所用的规则对它们进行排序。

例如,对于区域设置 ID“en-US”,当此属性为 true 时,字符串“version1”、“version10”和“version2”按以下顺序排序:version1 < version2 < version10。

对于“en-US”,当此属性为 false 时,上述同样的字符串按以下顺序排序:version1 < version10 < version2。

为此属性分配了值并且未引发错误或警告时,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

默认值为 false。



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

相关 API 元素

requestedLocaleIDName

属性 
requestedLocaleIDName:String  [只读]

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

传递到此 Collator 对象的构造函数的请求的区域设置 ID 名称。

如果使用了 LocaleID.DEFAULT 值,则返回的名称将是“i-default”。如果应用了回退区域设置,则实际使用的区域设置可能与请求的区域设置不同。可以使用 actualLocaleIDName 属性检索实际区域设置的名称。



实现
    public function get requestedLocaleIDName():String

相关 API 元素

构造函数详细信息

Collator

()构造函数
public function Collator(requestedLocaleIDName:String, initialMode:String = "sorting")

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

构造新的 Collator 对象,以根据指定的区域设置的约定提供字符串比较。

如果当前操作系统不支持在 requestedLocaleIDName 参数中传递到的区域设置 ID,则确定一个回退区域设置。如果使用了回退,则设置 lastOperationStatus 属性以表示回退类型。

initialMode 参数设置供常规使用的多种排序选项。它可以设置为下列值之一:

  • CollatorMode.SORTING:设置用于常规语言排序(例如对显示给最终用户的文本字符串列表进行排序)的排序选项。在此模式下,进行字符串比较时考虑大写和小写字母、重音符号及其它特定于区域设置的区别。
  • CollatorMode.MATCHING:设置供常规使用(例如确定两个字符串是否等效)的排序选项。在此模式下,进行字符串比较时忽略大写和小写字母、重音符号等区别。

以下是使用带有区域设置 ID“en-US”(美国英语)和 CollatorMode.SORTING 选项的 Collator 创建的排序列表的示例:

A一个ÄäAaAEaeÆæBbBbCcçCc

如上所示,所有字符均视为具有不同值,但按语言顺序排序。

以下是使用带有区域设置 ID“en-US”(美国英语)和 CollatorMode.MATCHING 选项的 Collator 创建的排序列表的示例:

A a Ä ä A aAE ae Æ æB b B bC c ç C c

如上所示,某些字符按语言顺序排序并被视为具有相同字符值。

要更细致的控制排序顺序,可以更改 Collator.ignoreCaseCollator.ignoreDiacritics 等 collator 属性。

作为参考,此处提供了一个使用不支持区域设置识别的标准 Array.sort() 完成排序的相应示例:

AAEBC一个aebcÄÆäæçABab

如上所示,所有字符均以 Unicode 数值顺序简单排序。在语言方面其意义并不大。

要使用用户的当前操作系统首选项,请将 requestedLocaleIDName 参数中的静态值 LocaleID.DEFAULT 传递到构造函数。

有些区域设置具有多种排序顺序变体。例如,在德语中,一种排序顺序用于电话号码簿,另一种排序顺序用于词典。中文中,通常对字提供字符音译为拼音的支持。可以通过在 requestedLocaleIDName 参数中传递给构造函数的字符串中包含“排序”关键字来选择这些不同的排序顺序。

         var germanPhonebook:LocaleID = new LocaleID("de-DE@collation=phonebook");
         var chinesePinyin:LocaleID = new LocaleID("zh-Hant@collation=pinyin");
         

排序字符串的可能值如下所示,括号中显示了所影响的语言:

排序字符串说明standard每种语言的默认顺序。 phonebook适用于电话簿样式顺序(用于德语)。pinyin适用于拉丁字符和 CJK 字符的拼音顺序;也就是基于逐字符音译为拼音的、适用于 CJK 字符的顺序。(用于中文)traditional适用于传统样式排序(用于西班牙语) stroke拼音顺序适用于拉丁语,笔顺适用于 CJK 字符(用于中文)direct(用于印地语) big5han拼音顺序适用于拉丁语,big5 字符集顺序适用于 CJK 字符。(用于中文) gb2312han 拼音顺序适用于拉丁语,gb2312han 字符集顺序适用于 CJK 字符。(用于中文) unihan拼音顺序适用于拉丁语,Unihan 字根比划顺序适用于 CJK 字符。(用于中文)

如果主机平台不支持请求的排序类型,则使用回退并设置 lastOperationStatus 属性,以表示选择了回退。可以使用 actualLocaleIDName 属性来确定用作回退的值,如下面的示例所示:

         var collator:Collator = new Collator("fr-FR");
         if (collator.lastOperationStatus == LastOperationStatus.USING_FALLBACK_WARNING)
         {
           trace ("Using fallback locale: " + collator.actualLocaleIDName);
         }
         

构造函数成功后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

当请求的区域设置 ID 不可用时,则将 lastOperationStatus 属性设置为下列属性值之一:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

有关上面列出的警告以及 lastOperationStatus 的其他可能值的详细信息,请参阅 LastOperationStatus 类中的说明。

参数
requestedLocaleIDName:String — 此 Collator 对象要使用的 String
 
initialMode:String (default = "sorting") — 用于指定初始排序模式的字符串值。默认值是 CollatorMode.SORTING。有关可用模式的列表,请参阅 CollatorMode 类。

引发
TypeError — 当 requestedLocaleIDName 参数为 null 时。
 
ArgumentError — 当 requestedLocaleIDName 参数包含无效值时。

相关 API 元素

方法详细信息

compare

()方法
public function compare(string1:String, string2:String):int

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

比较两个字符串并返回一个整数值,表示第一个字符串是小于、等于还是大于第二个字符串。比较将使用适用于 Collator() 构造函数中指定的区域设置 ID 的排序顺序规则。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

string1:String — 第一个比较字符串。
 
string2:String — 第二个比较字符串。

返回
int — 一个整数值,表示第一个字符串是小于、等于或大于第二个字符串。
  • 如果返回值为负,则表示 string1 小于 string2
  • 如果返回值是零,则表示 string1 等于 string2
  • 如果返回值为正,则表示 string1 大于 string2

引发
TypeError — 当必需的参数为空时。
 
ArgumentError — 当参数包含无效值时。

相关 API 元素

equals

()方法 
public function equals(string1:String, string2:String):Boolean

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

比较两个字符串并返回表示字符串是否相等的布尔值。比较将使用适用于 Collator() 构造函数中指定的区域设置 ID 的排序顺序规则。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

string1:String — 第一个比较字符串。
 
string2:String — 第二个比较字符串。

返回
Boolean — 一个布尔值,表示字符串相等 (true) 还是不相等 (false)。

引发
TypeError — 当必需的参数为空时。
 
ArgumentError — 当参数包含无效值时。

相关 API 元素

getAvailableLocaleIDNames

()方法 
public static function getAvailableLocaleIDNames():Vector.<String>

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

列出此类支持的所有区域设置 ID 名称。

如果当前操作系统根本不支持此类,此方法返回 null 值。

返回
Vector.<String> — 一个字符串矢量,其中包含此类支持的所有区域设置 ID 名称。
CollatorExample1.as

以下示例显示随区域设置而变化的排序结果。此示例执行下列步骤:
  1. 循环访问区域设置 ID 名称数组,包括操作系统的默认区域设置 ID(由 LocaleID.DEFAULT 指定)
  2. 使用“排序”模式(默认)为每个区域设置 ID 名称创建 Collator 对象。
  3. 显示请求的和实际的区域设置 ID 名称以及 lastOperationStatus 属性的值,以便能知道是否使用了回退区域设置。
  4. 使用每个 collator 对数据数组排序并显示排序结果。各区域设置的排序结果不同。
package {
    import flash.globalization.Collator;
    import flash.globalization.LocaleID;

    public class CollatorExample1
    {
        public var col:Collator;
        
        public function CollatorExample1():void
        {        
            var localeNames:Array = [LocaleID.DEFAULT,
                                     "de-DE", "sv-SE",
                                     "fr-FR", "lt-LT",
                                     "es-ES"];
            
            var testSortData:Array = [
                "y ", "i ", "k ", // Latvian
                "acxa ", "acha ", "adxa ", // es_traditional
                "n ", "ö ", "o ", "z ", "vu ", "wo ", // sw
                "däd ", "daed ", // de
                "öf ", "of ", // de_dictionary
                "côte ", "coté " // fr
            ];
            
            for each (var localeName:String in localeNames) {
            
                col = new Collator(localeName);
                
                trace("LocaleID requested: " + col.requestedLocaleIDName 
                       + "; actual: " + col.actualLocaleIDName);
                       
                trace("Last Operation Status: " + col.lastOperationStatus );
                
                var result:Array = testSortData.sort(col.compare);
                        
                trace ("sorted data: " + result); 
            }
        }      
    }
}
CollatorExample2.as

以下示例显示了使用 Collator 对象控制字符串比较的行为。此示例执行下列步骤:
  1. 使用“匹配”模式为用户的默认区域设置创建 Collator 对象。
  2. 交替将 Collator.ignoreDiacritics 属性设置为 falsetrue
  3. 比较多组包含音调符号和大小写字符的字符串。
  4. 显示当 Collator.ignoreDiacriticsCollator.ignoreCase 属性更改时比较如何变化。
package {
    import flash.display.Sprite;
    import flash.globalization.Collator;
    import flash.globalization.CollatorMode;
    import flash.globalization.LocaleID;
    
    public class CollatorExample2 extends Sprite
    {
        public var col:Collator;
        public var testMatchData:Array = ["cote", "Cote", "côte", "coté"];
        public var wordToMatch:String = "Cote";
        
        public function CollatorExample2()
        {
            col = new Collator( LocaleID.DEFAULT, CollatorMode.MATCHING );

            trace("LocaleID requested: " + col.requestedLocaleIDName 
                    + "; actual: " + col.actualLocaleIDName);
                    
            trace("Last Operation Status: " + col.lastOperationStatus );

            trace('\n' + "ignoreCase = " + col.ignoreCase);
            trace("ignoreDiacritics = " + col.ignoreDiacritics);

            compareString(testMatchData, wordToMatch) // All variations of the word cote match

            col.ignoreDiacritics = false;
            trace('\n' + "ignoreDiacritics = false");

            compareString(testMatchData, wordToMatch) // Variations with different diacritics will not match

            col.ignoreCase = false;
            trace('\n' + "ignoreCase = false");

            compareString(testMatchData, wordToMatch) // Variations with different case will not match
        }
    
        private function compareString(stringArray:Array, keyword:String):void
        {
            for each(var s:String in stringArray)
            {
                if(col.equals(s, keyword))    
                {
                    trace(keyword + " = " + s);
                }
            }
        }
    }
}




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

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