| 包 | flash.accessibility |
| 类 | public final class Accessibility |
| 继承 | Accessibility Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9 |
移动浏览器支持:移动浏览器不支持此类。
AIR 配置文件支持: 所有桌面操作系统均支持此功能,但移动设备或 AIR for TV 设备不支持此功能。有关在多个配置文件之间支持 API 的详细信息,请参阅 AIR 配置文件支持。
要获取和设置特定对象(例如按钮、影片剪辑或文本字段)的可访问属性,请使用 DisplayObject.accessibilityProperties 属性。要确定播放器或运行时是否正在支持辅助功能的环境中运行,请使用 Capabilities.hasAccessibility 属性。
注意:AIR 2 支持 JAWS 11(或更高版本)的屏幕阅读器软件。有关详细信息,请参阅 http://www.adobe.com/accessibility/。
了解详细信息
相关 API 元素
| 属性 | 由以下参数定义 | ||
|---|---|---|---|
| active : Boolean [静态] [只读]
表示某个屏幕阅读器是否处于活动状态,以及应用程序是否正在与之通信。 | Accessibility | ||
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
[静态]
通知 Flash Player 应用使用 DisplayObject.accessibilityProperties 属性所做的任何辅助功能更改。 | Accessibility | ||
![]() |
返回指定对象的原始值。 | Object | |
active | 属性 |
active:Boolean [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9 |
表示某个屏幕阅读器是否处于活动状态,以及应用程序是否正在与之通信。如果希望应用程序在有屏幕阅读器的情况下表现出不同的行为方式,可使用此方法。
将此属性设置为 true 后,它在应用程序运行期间将保持为 true。(用户通常不会在屏幕阅读器后启动关闭屏幕阅读器。)
注意:在启动 AIR 应用程序之后或在播放文档的 Flash® Player 窗口第一次出现之后,请等待 1 秒或 2 秒,再调用此方法。否则,即使存在活动的辅助功能客户端,也可能返回值 false。这是辅助功能客户端和 Flash Player 或 AIR 之间的异步通信机制造成的。
Capabilities.hasAccessibility 属性。
实现
public static function get active():Boolean相关 API 元素
updateProperties | () | 方法 |
public static function updateProperties():void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9 |
通知 Flash Player 应用使用 DisplayObject.accessibilityProperties 属性所做的任何辅助功能更改。需要调用此方法以使更改生效。
如果您修改多个对象的辅助功能属性,则只需调用 Accessibility.updateProperties() 方法一次;多次调用可能导致性能降低以及屏幕阅读器输出不正确。
引发
IllegalOperationError — 在此版本的 Flash Player 中不支持辅助功能。如果 flash.system.Capabilities.hasAccessibility 属性为 false,则不要调用 Accessibility.updateProperties() 方法。
|
相关 API 元素
AccessibilityExample、CustomAccessibleButton、CustomSimpleButton 和 ButtonDisplayState 范例类创建与辅助功能兼容且可用于大多数屏幕阅读器的菜单。该示例执行下列任务:
- 它跟踪
Accessibility.active属性,以确定屏幕阅读器当前是否处于活动状态,以及播放器是否正在与它通信。 - 如果
active属性返回true,该示例将调用updateProperties()方法来应用对本示例中的按钮进行的辅助功能更改。 - 该示例调用
flash.utils.setTimeout()方法,指定updateAccessibility()结束方法应在 2 秒钟之后调用。
注意:在检查 Accessibility.active 之前应先调用 setTimeout(),以给 Flash Player 提供与屏幕阅读器(如果有)连接所需的 2 秒钟时间。如果未提供足够长的延迟时间,则即使在有屏幕阅读器的情况下,setTimeout 调用也可能会返回 false。
只有在对 Accessibility.active 的调用返回 true 时(只有在 Flash Player 当前连接到活动的屏幕阅读器时才会发生这种情况),以下示例才会处理 Accessibility.updateProperties() 方法。如果在没有活动的屏幕阅读器的情况下调用 updateProperties,则会引发 IllegalOperationError 异常。
package {
import flash.display.Sprite;
import flash.accessibility.Accessibility;
import flash.utils.setTimeout;
public class AccessibilityExample extends Sprite {
public static const BUTTON_WIDTH:uint = 90;
public static const BUTTON_HEIGHT:uint = 20;
private var gutter:uint = 5;
private var menuLabels:Array = new Array("PROJECTS", "PORTFOLIO", "CONTACT");
private var menuDescriptions:Array = new Array("Learn more about our projects"
, "See our portfolio"
, "Get in touch with our team");
public function AccessibilityExample() {
configureAssets();
setTimeout(updateAccessibility, 2000);
}
private function updateAccessibility():void {
trace("Accessibility.active: " + Accessibility.active);
if(Accessibility.active) {
Accessibility.updateProperties();
}
}
private function configureAssets():void {
var child:CustomAccessibleButton;
for(var i:uint; i < menuLabels.length; i++) {
child = new CustomAccessibleButton();
child.y = (numChildren * (BUTTON_HEIGHT + gutter));
child.setLabel(menuLabels[i]);
child.setDescription(menuDescriptions[i]);
addChild(child);
}
}
}
}
import flash.accessibility.AccessibilityProperties;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextFormat;
import flash.text.TextField;
class CustomAccessibleButton extends Sprite {
private var button:SimpleButton;
private var label:TextField;
private var description:String;
private var _name:String;
public function CustomAccessibleButton(_width:uint = 0, _height:uint = 0) {
_width = (_width == 0) ? AccessibilityExample.BUTTON_WIDTH : _width;
_height = (_height == 0) ? AccessibilityExample.BUTTON_HEIGHT : _height;
button = buildButton(_width, _height);
label = buildLabel(_width, _height);
addEventListener(Event.ADDED, addedHandler);
}
private function addedHandler(event:Event):void {
trace("addedHandler: " + this._name);
var accessProps:AccessibilityProperties = new AccessibilityProperties();
accessProps.name = this._name;
accessProps.description = description;
accessibilityProperties = accessProps;
removeEventListener(Event.ADDED, addedHandler);
}
private function buildButton(_width:uint, _height:uint):SimpleButton {
var child:SimpleButton = new CustomSimpleButton(_width, _height);
addChild(child);
return child;
}
private function buildLabel(_width:uint, _height:uint):TextField {
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.size = 11;
format.color = 0xFFFFFF;
format.align = TextFormatAlign.CENTER;
format.bold = true;
var child:TextField = new TextField();
child.y = 1;
child.width = _width;
child.height = _height;
child.selectable = false;
child.defaultTextFormat = format;
child.mouseEnabled = false;
addChild(child);
return child;
}
public function setLabel(text:String):void {
label.text = text;
this._name = text;
}
public function setDescription(text:String):void {
description = text;
}
}
class CustomSimpleButton extends SimpleButton {
private var upColor:uint = 0xFFCC00;
private var overColor:uint = 0xCCFF00;
private var downColor:uint = 0x00CCFF;
public function CustomSimpleButton(_width:uint, _height:uint) {
downState = new ButtonDisplayState(downColor, _width, _height);
overState = new ButtonDisplayState(overColor, _width, _height);
upState = new ButtonDisplayState(upColor, _width, _height);
hitTestState = new ButtonDisplayState(upColor, _width, _height);
useHandCursor = true;
}
}
class ButtonDisplayState extends Shape {
private var bgColor:uint;
private var _width:uint;
private var _height:uint;
public function ButtonDisplayState(bgColor:uint, _width:uint, _height:uint) {
this.bgColor = bgColor;
this._width = _width;
this._height = _height;
draw();
}
private function draw():void {
graphics.beginFill(bgColor);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性