flash.accessibility
public final class Accessibility
继承Accessibility Inheritance Object

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

Accessibility 类管理与屏幕阅读器之间的通信。 屏幕读取器是一种辅助性技术,可以为视力有缺陷的用户提供屏幕内容的音频版本。 Accessibility 类的方法是静态方法,也就是说,您不必创建该类的实例即可使用其方法。

若要获取和设置特定对象(例如按钮、影片剪辑或文本字段)的可访问属性,请使用 DisplayObject.accessibilityProperties 属性。 若要确定播放器是否正在支持辅助功能的环境中运行,请使用 Capabilities.hasAccessibility 属性。

查看示例

另请参见

flash.display.DisplayObject.accessibilityProperties
flash.system.Capabilities.hasAccessibility
Socket



公共 属性
 属性定义方
  active : Boolean
[static] [read-only] 指示某个屏幕阅读器当前是否处于活动状态,以及播放器是否正在与它通信。
Accessibility
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 Inheritedprototype : Object
[static] 对类或函数对象的原型对象的引用。
Object
公共 方法
 方法定义方
 Inherited
指示对象是否已经定义了指定的属性。
Object
 Inherited
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
  
[static] 通知 Flash Player 应用使用 DisplayObject.accessibilityProperties 属性所做的任何辅助功能更改。
Accessibility
 Inherited
返回指定对象的原始值。
Object
属性详细信息
active属性
active:Boolean  [read-only]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

指示某个屏幕阅读器当前是否处于活动状态,以及播放器是否正在与它通信。 如果希望应用程序在有屏幕阅读器的情况下表现出不同的行为方式,可使用此方法。

注意:如果在播放文档的 Flash® 窗口第一次出现后 1 秒或 2 秒的时间内调用此方法,则可能获得返回值 false,即使有活动辅助功能客户端也是如此。 这是由于 Flash 和辅助功能客户端之间的异步通信机制造成的。 您可以通过确保在加载您的文档后延迟 1 秒到 2 秒再调用此方法,来解决这一限制问题。

若要确定播放器是否正在支持屏幕读取器的环境中运行,请使用 Capabilities.hasAccessibility 属性。


实现
    public static function get active():Boolean

另请参见

方法详细信息
updateProperties()方法
public static function updateProperties():void

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

通知 Flash Player 应用使用 DisplayObject.accessibilityProperties 属性所做的任何辅助功能更改。 需要调用此方法以使更改生效。

如果您修改多个对象的辅助功能属性,则只需调用 Accessibility.updateProperties() 方法一次;多次调用可能导致性能降低以及屏幕阅读器输出不正确。


引发
IllegalOperationError — 在此版本的 Flash Player 中不支持辅助功能。 如果 flash.system.Capabilities.hasAccessibility 属性为 false,则不要调用 Accessibility.updateProperties() 方法。

另请参见

示例 如何使用示例

下例使用 AccessibilityExampleCustomAccessibleButtonCustomSimpleButtonButtonDisplayState 范例类创建与辅助功能兼容且可用于大多数屏幕阅读器的菜单。 该示例执行下列任务:
  1. 它跟踪 Accessibility.active 属性,以确定屏幕阅读器当前是否处于活动状态,以及播放器是否正在与它通信。
  2. 如果 active 属性返回 true,该示例将调用 updateProperties() 方法来应用对本示例中的按钮进行的辅助功能更改。
  3. 该示例调用 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();
    }
}




 

评论添加到页面后给我发送电子邮件 | 评论报告

当前页: http://livedocs.adobe.com/flash/9.0_cn/ActionScriptLangRefV3/flash/accessibility/Accessibility.html