Package | flash.accessibility |
Class | public class AccessibilityProperties |
Inheritance | AccessibilityProperties Object |
Subclasses | UIComponentAccImpl, UIComponentAccProps |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
You can attach an AccessibilityProperties object to any display object, but Flash Player will read
your AccessibilityProperties object only for certain kinds of objects: 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 specify 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. The AccessibilityProperties.name
property is a name
that is read aloud by the accessibility aids, whereas DisplayObject.name
is essentially a
variable name visible only to ActionScript code.
In Flash Professional, the properties of AccessibilityProperties
objects override
the corresponding settings available in the Accessibility panel during authoring.
To determine whether Flash 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.
Related API Elements
flash.display.DisplayObject.accessibilityProperties
flash.display.InteractiveObject.tabIndex
flash.system.Capabilities.hasAccessibility
Property | Defined By | ||
---|---|---|---|
constructor : 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 | ||
prototype : 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 |
Method | Defined By | ||
---|---|---|---|
Creates a new AccessibilityProperties object. | AccessibilityProperties | ||
Indicates whether an object has a specified property defined. | Object | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object |
description | property |
public var description:String
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
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. The default value
is an empty string.
In Flash Professional, this property corresponds to the Description field in the Accessibility panel.
forceSimple | property |
public var forceSimple:Boolean
Runtime Versions: | AIR 1.0, Flash Player 9 |
If true
, causes Flash Player to exclude child objects within this
display object from the accessible presentation.
The default is false
. Applies to whole SWF files and containers.
name | property |
public var name:String
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
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. The default value
is an empty string.
In Flash Professional, this property corresponds to the Name field in the Accessibility panel.
noAutoLabeling | property |
public var noAutoLabeling:Boolean
Runtime Versions: | AIR 1.0, Flash Player 9 |
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.
The default is false
. Applies only to whole SWF files.
The noAutoLabeling
property value is ignored unless you specify it before the
first time an accessibility aid examines your SWF file. If you plan to set
noAutoLabeling
to true
, you should do so as early as
possible in your code.
shortcut | property |
public var shortcut:String
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
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. The default value is an empty string.
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
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
If true
, excludes this display object from accessible presentation.
The default is false
. Applies to whole SWF files, containers, buttons, and text.
AccessibilityProperties | () | Constructor |
public function AccessibilityProperties()
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
Creates a new AccessibilityProperties object.
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:
- 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. - 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
.
to give Flash Player the 2 seconds it needs to connect to a screen reader,
if one is available. If you do not provide 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 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.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 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(); } } }
Mon Nov 28 2011, 06:48 AM -08:00