Packageflash.accessibility
Classpublic class AccessibilityProperties
InheritanceAccessibilityProperties Inheritance Object

The AccessibilityProperties class lets you control the presentation of Flash objects to accessibility aids, such as screen readers.

You can attach an AccessibilityProperties object to any DisplayObject, but Flash Player will read your AccessibilityProperties object only for certain kinds of objects. These objects include entire SWF files (as represented by DisplayObject.root), container objects (DisplayObjectContainer and subclasses), buttons (SimpleButton and subclasses), and text (TextField and subclasses).

The name property of these objects is the most important property to provide because accessibility aids provide the names of objects to users as a basic means of navigation. Do not confuse AccessibilityProperties.name with DisplayObject.name; these are separate and unrelated properties. AccessibilityProperties.name is a human-readable name to be announced by accessibility aids, while DisplayObject.name is essentially a variable name visible only to ActionScript code.

The properties of AccessibilityProperties objects override the corresponding settings available in the Accessibility panel during authoring.

To determine whether the player is running in an environment that supports accessibility aids, use the Capabilities.hasAccessibility property. If you modify AccessibilityProperties objects, you need to call the Accessibility.updateProperties() method for the changes to take effect.

The following Property table lists the name and data type of each property its equivalent setting in the Accessibility panel, and the kinds of objects to which the property can be applied.

View the examples.

See also
flash.accessibility.Accessibility.updateProperties(), flash.system.Capabilities.hasAccessibility, flash.display.DisplayObject.accessibilityProperties, flash.display.InteractiveObject.tabIndex


Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  description : String
Provides a description for this display object in the accessible presentation.
AccessibilityProperties
  forceSimple : Boolean
If true, causes Flash Player to exclude child objects within this display object from the accessible presentation.
AccessibilityProperties
  name : String
Provides a name for this display object in the accessible presentation.
AccessibilityProperties
  noAutoLabeling : Boolean
If true, disables the Flash Player default auto-labeling system.
AccessibilityProperties
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  shortcut : String
Indicates a keyboard shortcut associated with this display object.
AccessibilityProperties
  silent : Boolean
If true, excludes this display object from accessible presentation.
AccessibilityProperties
Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods
 FunctionDefined by
  
Creates a new AccessibilityProperties object.
AccessibilityProperties
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property detail
description property
public var description:String

Provides a description for this display object in the accessible presentation. If you have a lot of information to present about the object, it is best to choose a concise name and put most of your content in the description property. Applies to whole SWF files, containers, buttons, and text.
forceSimple property
public var forceSimple:Boolean

If true, causes Flash Player to exclude child objects within this display object from the accessible presentation. Defaults to false. Applies to whole SWF files and containers.
name property
public var name:String

Provides a name for this display object in the accessible presentation. Applies to whole SWF files, containers, buttons, and text. Do not confuse with DisplayObject.name, which is unrelated.
noAutoLabeling property
public var noAutoLabeling:Boolean

If true, disables the Flash Player default auto-labeling system. Auto-labeling causes text objects inside buttons to be treated as button names, and text objects near text fields to be treated as text field names. Defaults to false. Applies only to whole SWF files.
shortcut property
public var shortcut:String

Indicates a keyboard shortcut associated with this display object. Supply this string only for UI controls that you have associated with a shortcut key. Applies to containers, buttons, and text.

Note: Assigning this property does not automatically assign the specified key combination to this object; you must do that yourself, for example, by listening for a KeyboardEvent.

The syntax for this string uses long names for modifier keys, and the plus(+) character to indicate key combination. Examples of valid strings are "Ctrl+F", "Ctrl+Shift+Z", and so on.

silent property
public var silent:Boolean

If true, excludes this display object from accessible presentation. Defaults to false. Applies to whole SWF files, containers, buttons, and text.
Constructor detail
AccessibilityProperties constructor

public function AccessibilityProperties()

Creates a new AccessibilityProperties object.
Class examples

The following example uses the AccessibilityExample, CustomAccessibleButton, CustomSimpleButton, and ButtonDisplayState classes to create an accessibility-compliant menu that works with common screen readers. The main functionality of the AccessibilityProperties class is as follows:
  1. Call configureAssets, which creates a custom button and sets its label and description. These are the values that the screen reader conveys to the end user.
  2. Call setTimeOut() to ensure that Flash Player has enough time to detect the screen reader before updating the properties.

Note: Call setTimeout() before checking Accessibility.active. Do so to give Flash Player the two seconds it needs to connect to a screen reader if one is available. The setTimeout call may return false even if a screen reader is available unless a sufficient delay time is provided.

Also note: This example only processes the Accessibility.updateProperties() method if the call to Accessibility.active returns true, which can only happen if Flash Player is currently connected to an active screen reader. If updateProperties is called without an active screen reader, it throws an IllegalOperationError handler.

package {
    import flash.display.Sprite;
    import flash.accessibility.Accessibility;
    import flash.utils.setTimeout;
    
    public class AccessibilityPropertiesExample 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 AccessibilityPropertiesExample() {
            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.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 label1:TextField;
    private var description:String;
    private var _name:String;
        
    public function CustomAccessibleButton(_width:uint = 0, _height:uint = 0) {
        _width = (_width == 0) ? AccessibilityPropertiesExample.BUTTON_WIDTH : _width;
        _height = (_height == 0) ? AccessibilityPropertiesExample.BUTTON_HEIGHT : _height;
            
        button = buildButton(_width, _height);
        label1 = buildLabel(_width, _height);
            
        addEventListener(Event.ADDED, addedHandler);
    }
        
    private function addedHandler(event:Event):void {
        trace("addedHandler: " + 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 {
        label1.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();
    }
}
}




 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/labs/flashauthoringpreview/flash/accessibility/AccessibilityProperties.html