ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
Accessibility

Package | flash.accessibility
Class | public final class Accessibility
Inheritance | Accessibility Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

The Accessibility class manages communication with screen readers. Screen readers are a type of assistive technology for visually impaired users that provides an audio version of screen content. The methods of the Accessibility class are static—that is, you don't have to create an instance of the class to use its methods.

To get and set accessible properties for a specific object, such as a button, movie clip, or text field, use the `DisplayObject.accessibilityProperties` property. To determine whether the player is running in an environment that supports accessibility aids, use the `Capabilities.hasAccessibility` property.

View the examples

See also

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

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | active : Boolean [static] [read-only] Indicates whether a screen reader is currently active and the player is communicating with it. | Accessibility
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | updateProperties():void [static] Tells Flash Player to apply any accessibility changes made by using the DisplayObject.accessibilityProperties property. | Accessibility
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

active | property

`active:Boolean` [read-only]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Indicates whether a screen reader is currently active and the player is communicating with it. Use this method when you want your application to behave differently in the presence of a screen reader.

Note: If you call this method within 1 or 2 seconds of the first appearance of the Flash® window in which your document is playing, you might get a return value of `false` even if there is an active accessibility client. This happens because of an asynchronous communication mechanism between Flash and accessibility clients. You can work around this limitation by ensuring a delay of 1 to 2 seconds after loading your document before calling this method.

To determine whether the player is running in an environment that supports screen readers, use the `Capabilities.hasAccessibility` property.
Implementation
`public static function get active():Boolean`

See also

flash.system.Capabilities.hasAccessibility
updateProperties()
Method Detail

updateProperties | () | method

`public static function updateProperties():void`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Tells Flash Player to apply any accessibility changes made by using the `DisplayObject.accessibilityProperties` property. You need to call this method for your changes to take effect.

If you modify the accessibility properties for multiple objects, only one call to the `Accessibility.updateProperties()` method is necessary; multiple calls can result in reduced performance and erroneous screen reader output.

Throws

| `IllegalOperationError` — Accessibility is not supported in this version of Flash Player. Do not call the `Accessibility.updateProperties()` method if the `flash.system.Capabilities.hasAccessibility` property is `false`.

See also

active
flash.display.DisplayObject.accessibilityProperties
flash.system.Capabilities.hasAccessibility
Examples How to use examples
AccessibilityExample.as
The following example uses `AccessibilityExample`, `CustomAccessibleButton`, `CustomSimpleButton`, and `ButtonDisplayState` sample classes to create an accessibility-compliant menu that works with most screen readers. The example carries out the following tasks:

1. It traces the `Accessibility.active` property to determine whether a screen reader is currently active and the player is communicating with it.
2. If the `active` property returns `true`, the example calls the `updateProperties()` method to apply the accessibility changes made to the buttons in this example.
3. The example calls the `flash.utils.setTimeout()` method, specifying that the `updateAccessibility()` closure method should be called after 2 seconds.

Note: Call `setTimeout()` before checking `Accessibility.active` to give Flash Player the 2 seconds it needs to connect to a screen reader if one is available. If you do not supply a sufficient delay time, the `setTimeout` call might return `false` even if a screen reader is available.

The following example processes the `Accessibility.updateProperties()` method only if the call to `Accessibility.active` returns `true`, which occurs only if Flash Player is currently connected to an active screen reader. If `updateProperties` is called without an active screen reader, it throws an `IllegalOperationError` exception.

    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();
        }
    }

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00