Adobe® Flex® 4 Language Reference
Hide Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
flash.accessibility 
AccessibilityImplementation 
Packageflash.accessibility
Classpublic class AccessibilityImplementation
InheritanceAccessibilityImplementation Inheritance Object
Subclasses AccImpl

Runtime Versions: AIR 1.0 Flash Player 9

The AccessibilityImplementation class is the base class in Flash Player that allows for the implementation of accessibility in components. This class enables communication between a component and a screen reader. Screen readers are used to translate screen content into synthesized speech or braille for visually impaired users.

The AccessibilityImplementation class provides a set of methods that allow a component developer to make information about system roles, object based events, and states available to assistive technology.

Adobe Flash Player uses Microsoft Active Accessibility (MSAA), which provides a descriptive and standardized way for applications and screen readers to communicate. For more information on how the Flash Player works with MSAA, see the accessibility chapter in Using Flex SDK.

The methods of the AccessibilityImplementation class are a subset of the IAccessible interface for a component instance.

The way that an AccessibilityImplementation implements the IAccessible interface, and the events that it sends, depend on the kind of component being implemented.

Do not directly instantiate AccessibilityImplementation by calling its constructor. Instead, create new accessibility implementations by extending the Flex mx.accessibility.AccImpl class for each new component. See the accessibility chapter in Using Flex SDK.

Note: The AccessibilityImplementation class is not supported in AIR runtime versions. The class is available for compilation, but is not supported by the AIR runtime.



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  errno : uint
Errors are indicated out-of-band, rather than in return values.
AccessibilityImplementation
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  stub : Boolean
If a component is released without an ActionScript accessibility implementation, it is strongly suggested that a component accessibility stub be included.
AccessibilityImplementation
Public Methods
 MethodDefined By
  
Do not directly instantiate AccessibilityImplementation by calling its constructor.
AccessibilityImplementation
  
An IAccessible method that performs the default action associated with the component that this AccessibilityImplementation represents or of one of its child elements.
AccessibilityImplementation
  
accLocation(childID:uint):*
MSAA method for returning a DisplayObject or Rectangle specifying the bounding box of a child element in the AccessibilityImplementation.
AccessibilityImplementation
  
accSelect(selFlag:uint, childID:uint):void
IAccessible method for altering the selection in the component that this AccessibilityImplementation represents.
AccessibilityImplementation
  
MSAA method for returning the default action of the component that this AccessibilityImplementation represents or of one of its child elements.
AccessibilityImplementation
  
MSAA method for returning the unsigned integer ID of the child element, if any, that has child focus within the component.
AccessibilityImplementation
  
MSAA method for returning the name for the component that this AccessibilityImplementation represents or for one of its child elements.
AccessibilityImplementation
  
MSAA method for returning the system role for the component that this AccessibilityImplementation represents or for one of its child elements.
AccessibilityImplementation
  
MSAA method for returning an array containing the IDs of all child elements that are selected.
AccessibilityImplementation
  
IAccessible method for returning the current runtime state of the component that this AccessibilityImplementation represents or of one of its child elements.
AccessibilityImplementation
  
MSAA method for returning the runtime value of the component that this AccessibilityImplementation represents or of one of its child elements.
AccessibilityImplementation
  
Returns an array containing the unsigned integer IDs of all child elements in the AccessibilityImplementation.
AccessibilityImplementation
 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 this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

errno

property
public var errno:uint

Runtime Versions: AIR 1.0 Flash Player 9

Errors are indicated out-of-band, rather than in return values. To indicate an error, set the errno property to one of the error codes documented in the AccessibilityImplementation Constants appendix. This causes your return value to be ignored. The errno property of your AccessibilityImplementation is always cleared (set to zero) by the player before any AccessibilityImplementation method is called.

See also

stub

property 
public var stub:Boolean

Runtime Versions: AIR 1.0 Flash Player 9

If a component is released without an ActionScript accessibility implementation, it is strongly suggested that a component accessibility stub be included. This stub causes Flash Player, for accessibility purposes, to treat the component as a simple graphic rather than exposing the internal structure of buttons, textfields, and so on, within the component.

To create a Flex component accessibility stub, subclass the mx.accessibility.AccImpl class, overriding the property stub with a value of true.

See also

The mx.accessibility.AccImpl class in Flex (\sdks\4.0.0\frameworks\projects\framework\src\mx\accessibility\AccImpl.as)
Constructor Detail

AccessibilityImplementation

()Constructor
public function AccessibilityImplementation()

Runtime Versions: AIR 1.0 Flash Player 9

Do not directly instantiate AccessibilityImplementation by calling its constructor. Instead, create new accessibility implementations by extending the Flex mx.accessibility.AccImpl class for each new component.

See also

The mx.accessibility.AccImpl class in Flex (\sdks\4.0.0\frameworks\projects\framework\src\mx\accessibility\AccImpl.as)
Method Detail

accDoDefaultAction

()method
public function accDoDefaultAction(childID:uint):void

Runtime Versions: AIR 1.0 Flash Player 9

An IAccessible method that performs the default action associated with the component that this AccessibilityImplementation represents or of one of its child elements.

Implement this method only if the AccessibilityImplementation represents a UI element that has a default action in the MSAA model.

If you are implementing accDoDefaultAction() only for the AccessibilityImplementation itself, or only for its child elements, you will need in some cases to indicate that there is no default action for the particular childID that was passed. Do this by setting the errno property to E_MEMBERNOTFOUND.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements, as defined by getChildIDArray().


Example  ( How to use this example )
Following is an example showing how this method is implemented to perform the appropriate default action in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase Accessibility Implementation. For the ListBase and classes that inherit from it, performing the default action "Double Click" for one of its child list item elements selects that element.
     override public function accDoDefaultAction(childID:uint):void
     {
         if (childID > 0)
             ListBase(master).selectedIndex = childID - 1;
     }

accLocation

()method 
public function accLocation(childID:uint):*

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning a DisplayObject or Rectangle specifying the bounding box of a child element in the AccessibilityImplementation.

This method is never called with a childID of zero. If your AccessibilityImplementation will never contain child elements, you should not implement this method. If your AccessibilityImplementation can contain child elements, this method is mandatory.

You can usually satisfy the requirements of this method by returning an object that represents the child element itself. This works as long as the child element is a DisplayObject. In these cases, simply return the DisplayObject that corresponds to the instance name associated with the relevant visual object in display list.

If a child element does not qualify for the technique described above, you may do the bounding-box math yourself and return a Rectangle with: x, y, width, and height properties. The x and y members specify the upper-left corner of the bounding box, and the width and height members specify its size. All four members should be in units of Stage pixels, and relative to the origin of the component that the AccessibilityImplementation represents. The x and y properties may have negative values, since the origin of a DisplayObject is not necessarily in its upper-left corner.

If the child element specified by childID is not visible (that is, get_accState for that child would return a value including STATE_SYSTEM_INVISIBLE), you may return null from accLocation. You can also return a Rectangle representing the coordinates where the child element would appear if it were visible.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements as defined by getChildIDArray().

Returns
*DisplayObject or Rectangle specifying the bounding box of the child element specified by childID parameter.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to return the location of a given child element in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
     override public function accLocation(childID:uint):*
     
     {
         var listBase:ListBase = ListBase(master);
     
         var index:uint = childID - 1;
         
         if (index < listBase.verticalScrollPosition ||
             index >= listBase.verticalScrollPosition + listBase.rowCount)
         {
             return null;
         }
         var item:Object = getItemAt(index);
     
         return listBase.itemToItemRenderer(item);
     }
     

accSelect

()method 
public function accSelect(selFlag:uint, childID:uint):void

Runtime Versions: AIR 1.0 Flash Player 9

IAccessible method for altering the selection in the component that this AccessibilityImplementation represents.

The childID parameter will always be nonzero. This method always applies to a child element rather than the overall component; Flash Player manages the selection of the overall component itself.

The selFlag parameter is a bitfield consisting of one or more selection flag constants that allows an MSAA client to indicate how the item referenced by the childID should be selected or take focus. What follows are descriptions of the selection flag constants and what they communicate to the accessibility implementation. As a practical matter, most implementations of this method in accessibility implementations that inherit from the Flex mx.accessibility.ListBaseAccImpl class ignore the selFlag constant and instead rely on the component's keyboard selection behavior to handle multi-selection.

The selFlag parameter may or may not contain the SELFLAG_TAKEFOCUS flag. If it does, you should set the child focus to the specified childID, and, unless SELFLAG_EXTENDSELECTION is also present, make that child element the selection anchor. Otherwise, the child focus and selection anchor should remain unmodified, despite the fact that additional flags described below may modify the selection.

The selFlag argument will always contain one of the following four flags, which indicate what kind of selection modification is desired:

  • SELFLAG_TAKESELECTION: Clear any existing selection, and set the selection to the specified childID.

  • SELFLAG_EXTENDSELECTION: Calculate the range of child elements between and including the selection anchor and the specified childID. If SELFLAG_ADDSELECTION is present, add all of these child elements to the selection. If SELFLAG_REMOVESELECTION is present, remove all of these child elements from the selection. If neither SELFLAG_ADDSELECTION nor SELFLAG_REMOVESELECTION is present, all of these child elements should take on the selection anchor's selection state: if the selection anchor is selected, add these child elements to the selection; otherwise remove them from the selection.

  • SELFLAG_ADDSELECTION (without SELFLAG_EXTENDSELECTION): Add the specified childID to the selection.

  • SELFLAG_REMOVESELECTION (without SELFLAG_EXTENDSELECTION): Remove the specified childID from the selection.

Note that for a non-multi-selectable component, the only valid selFlag parameter values are SELFLAG_TAKEFOCUS and SELFLAG_TAKESELECTION. You could in theory also choose to support SELFLAG_REMOVESELECTION for a non-multi-selectable component that allowed the user to force a null selection, but in practice most non-multi-selectable components do not work this way, and MSAA clients may not attempt this type of operation.

If you encounter flags that seem invalid, set errno to E_INVALIDARG.

Finally, note that when accSelect is called, Flash Player ensures that it has host focus (the window focus of its container application), and that your component has focus within Flash Player.

Parameters

selFlag:uint — A bitfield consisting of one or more selection flag constants to indicate how the item is selected or takes focus.
 
childID:uint — An unsigned integer corresponding to one of the component's child elements as defined by getChildIDArray().

See also


Example  ( How to use this example )
The following example shows how this method is implemented to select a child item in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
override public function accSelect(selFlag:uint, childID:uint):void
     {
         
         var listBase:ListBase = ListBase(master);
         
         var index:uint = childID - 1;
         
         if (index >= 0 && index < listBase.dataProvider.length)
             listBase.selectedIndex = index;
     }
     

get_accDefaultAction

()method 
public function get_accDefaultAction(childID:uint):String

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning the default action of the component that this AccessibilityImplementation represents or of one of its child elements.

Implement this method only if the AccessibilityImplementation represents a UI element that has a default action in the MSAA model; be sure to return the exact string that the MSAA model specifies. For example, the default action string for a Button component is "Press."

If you are implementing get_accDefaultAction only for the AccessibilityImplementation itself, or only for its child elements, you will need in some cases to indicate that there is no default action for the particular childID that was passed. Do this by simply returning null.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements, as defined by getChildIDArray().

Returns
String — The default action string specified in the MSAA model for the AccessibilityImplementation or for one of its child elements.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to return the appropriate default actions in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
override public function get_accDefaultAction(childID:uint):String
     {
         if (childID == 0)
             return null;
     
         return "Double Click";
     }

get_accFocus

()method 
public function get_accFocus():uint

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning the unsigned integer ID of the child element, if any, that has child focus within the component. If no child has child focus, the method returns zero.

Returns
uint — The unsigned integer ID of the child element, if any, that has child focus within the component.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to return the focused childID in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
override public function get_accFocus():uint
     {
     var index:uint = ListBase(master).selectedIndex;
     
     return index >= 0 ? index + 1 : 0;
     }

get_accName

()method 
public function get_accName(childID:uint):String

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning the name for the component that this AccessibilityImplementation represents or for one of its child elements.

In the case of the AccessibilityImplementation itself (childID == 0), if this method is not implemented, or does not return a value, Flash Player uses the AccessibilityProperties.name property value, if it is present.

For AccessibilityImplementations that can have child elements, this method must be implemented, and must return a string value when childID is nonzero.

Depending on the type of user interface element, names in MSAA mean one of two different things: an author-assigned name, or the actual text content of the element. Usually, an AccessibilityImplementation itself will fall into the former category. Its name property is an author-assigned name. Child elements always fall into the second category. Their names indicate their text content.

When the name property of an AccessibilityImplementation has the meaning of an author-assigned name, there are two ways in which components can acquire names from authors. The first entails names present within the component itself; for example, a checkbox component might include a text label that serves as its name. The second—a fallback from the first—entails names specified in the UI and ending up in AccessibilityProperties.name. This fallback option allows users to specify names just as they would for any other Sprite or MovieClip.

This leaves three possibilities for the AccessibilityImplementation itself (childID == zero):

  • Author-assigned name within component. The get_accName method should be implemented and should return a string value that contains the AccessibilityImplementation's name when childID is zero. If childID is zero but the AccessibilityImplementation has no name, get_accName should return an empty string to prevent the player from falling back to the AccessibilityProperties.name property.

  • Author-assigned name from UI. If the AccessibilityImplementation can have child elements, the get_accName method should be implemented but should not return a value when childID is zero. If the AccessibilityImplementation will never have child elements, get_accName should not be implemented.

  • Name signifying content. The get_accName method should be implemented and should return an appropriate string value when childID is zero. If childId is zero but the AccessibilityImplementation has no content, get_accName should return an empty string to prevent the player from falling back to the AccessibilityProperties.name property.

Note that for child elements (if the AccessibilityImplementation can have them), the third case always applies. The get_accName method should be implemented and should return an appropriate string value when childID is nonzero.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements as defined by getChildIDArray().

Returns
String — Name of the component or one of its child elements.

See also

getChildIDArray()
flash.accessibility.AccessibilityProperties
flash.accessibility.AccessibilityProperties.name
Flex mx.accessibility.AccImpl.get_accName() method
Flex mx.accessibility.AccImpl.getName() method
Flex mx.accessibility.AccImpl.getStatusName() method
Microsoft Accessibility Developer Center: IAccessible::get_accName

Example  ( How to use this example )
The following example shows how this method is implemented in the Flex mx.accessibility.AccImpl class, the base accessibility implementation in Flex.
override public function get_accName(childID:uint):String
     {
         // Start with the name of the component's parent form 
          // if the component is contained within a form
         var accName:String = UIComponentAccImpl.getFormName(master);
     
         // If the element requested is the component itself, 
         // append the value of any assigned accessibilityProperties.name    
         if (childID == 0 && master.accessibilityProperties 
             && master.accessibilityProperties.name 
                 && master.accessibilityProperties.name != "")
             accName += master.accessibilityProperties.name + " ";
     
         // Append the value of the childIDs name 
     // returned by the component-specific override 
     // of the mx.accessibility.AccImpl.getName() utility function,
         // and append the component's status returned by the 
     // component-specific override of the 
     // mx.accessibility.AccImpl.getStatusName() utility function
         accName += getName(childID) + getStatusName();
     
     // Return the assembled String if it is neither empty nor null, 
     // otherwise return null
         return (accName != null && accName != "") ? accName : null;
     }

get_accRole

()method 
public function get_accRole(childID:uint):uint

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning the system role for the component that this AccessibilityImplementation represents or for one of its child elements. System roles are predefined for all the components in MSAA.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements as defined by getChildIDArray().

Returns
uint — System role associated with the component.

Throws
Error — Error code 2143, AccessibilityImplementation.get_accRole() must be overridden from its default.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to return the appropriate system role constant for the component itself or for one of its list items in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
override public function get_accRole(childID:uint):uint
     {
         if (childID == 0)
             return role;
             
         return ROLE_SYSTEM_LISTITEM;
     }

get_accSelection

()method 
public function get_accSelection():Array

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning an array containing the IDs of all child elements that are selected. The returned array may contain zero, one, or more IDs, all unsigned integers.

Returns
Array — An array of the IDs of all child elements that are selected.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to return the selected childIDs in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
     override public function get_accSelection():Array
     {
         var accSelection:Array = [];
     
         var selectedIndices:Array = ListBase(master).selectedIndices;
         
         var n:int = selectedIndices.length;
         for (var i:int = 0; i < n; i++)
         {
             accSelection[i] = selectedIndices[i] + 1;
         }
         
         return accSelection;
     }
     

get_accState

()method 
public function get_accState(childID:uint):uint

Runtime Versions: AIR 1.0 Flash Player 9

IAccessible method for returning the current runtime state of the component that this AccessibilityImplementation represents or of one of its child elements.

This method must return a combination of zero, one, or more of the predefined object state constants for components in MSAA. When more than one state applies, the state constants should be combined into a bitfield using |, the bitwise OR operator.

To indicate that none of the state constants currently applies, this method should return zero.

You should not need to track or report the STATE_SYSTEM_FOCUSABLE or STATE_SYSTEM_FOCUSED states. Flash Player handles these states automatically.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements as defined by getChildIDArray().

Returns
uint — A combination of zero, one, or more of the system state constants. Multiple constants are assembled into a bitfield using |, the bitwise OR operator.

Throws
Error — Error code 2144, AccessibilityImplementation.get_accState() must be overridden from its default.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to combine more than one state constant in mx.accessibility.ListBaseAccImpl, the Flex ListBase Accessibility Implementation.
     override public function get_accState(childID:uint):uint
     {
         var accState:uint = getState(childID);
     
         if (childID > 0) 
         {
             var listBase:ListBase = ListBase(master);
     
             var index:uint = childID - 1;
     
             // For returning states (OffScreen and Invisible)
             // when the list Item is not in the displayed rows.
             if (index < listBase.verticalScrollPosition ||
                 index >= listBase.verticalScrollPosition + listBase.rowCount)
             {
                 accState |= (STATE_SYSTEM_OFFSCREEN |
                              STATE_SYSTEM_INVISIBLE);
             }
             else
             {
                 accState |= STATE_SYSTEM_SELECTABLE;
     
                 var item:Object = getItemAt(index);
     
                 var renderer:IListItemRenderer =
                     listBase.itemToItemRenderer(item);
     
                 if (renderer != null && listBase.isItemSelected(renderer.data))
                     accState |= STATE_SYSTEM_SELECTED | STATE_SYSTEM_FOCUSED;
             }
         }
     
         return accState;
     }

get_accValue

()method 
public function get_accValue(childID:uint):String

Runtime Versions: AIR 1.0 Flash Player 9

MSAA method for returning the runtime value of the component that this AccessibilityImplementation represents or of one of its child elements.

Implement this method only if your AccessibilityImplementation represents a UI element that has a value in the MSAA model. Be aware that some UI elements that have an apparent 'value' actually expose this value by different means, such as get_accName (text, for example), get_accState (check boxes, for example), or get_accSelection (list boxes, for example).

If you are implementing get_accValue only for the AccessibilityImplementation itself, or only for its child elements, you will need in some cases to indicate that there is no concept of value for the particular childID that was passed. Do this by simply returning null.

Parameters

childID:uint — An unsigned integer corresponding to one of the component's child elements as defined by getChildIDArray().

Returns
String — A string representing the runtime value of the component of of one of its child elements.

See also


Example  ( How to use this example )
The following example shows how this method is implemented to return the appropriate value based on the component's selectedIndex value in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase accessibility implementation.
override public function get_accValue(childID:uint):String
     {
         var accValue:String;
         
         var listBase:ListBase = ListBase(master);
         
         var index:int = listBase.selectedIndex;
         if (childID == 0)
         {
             if (index > -1)
             {
                 var item:Object = getItemAt(index);
     
                 if (item is String)
                 {
                     accValue = item + " " + (index + 1) + " of " + listBase.dataProvider.length;
                 }
                 else
                 {
                     accValue = listBase.itemToLabel(item) + " " + (index + 1) +
                                " of " + listBase.dataProvider.length;
                 }
             }
         }
     
         return accValue;
     }

getChildIDArray

()method 
public function getChildIDArray():Array

Runtime Versions: AIR 1.0 Flash Player 9

Returns an array containing the unsigned integer IDs of all child elements in the AccessibilityImplementation.

The length of the array may be zero. The IDs in the array should appear in the same logical order as the child elements they represent. If your AccessibilityImplementation can contain child elements, this method is mandatory; otherwise, do not implement it.

In assigning child IDs to your child elements, use any scheme that preserves uniqueness within each instance of your AccessibilityImplementation. Child IDs need not be contiguous, and their ordering need not match the logical ordering of the child elements. You should arrange so as to not reuse child IDs; if a child element is deleted, its ID should never be used again for the lifetime of that AccessibilityImplementation instance. Be aware that, due to implementation choices in the Flash player code, undesirable behavior can result if you use child IDs that exceed one million.

Returns
Array — Array containing the unsigned integer IDs of all child elements in the AccessibilityImplementation.

Example  ( How to use this example )
The following example shows how this method is implemented to return an array of childIDs in the Flex mx.accessibility.ListBaseAccImpl class, the ListBase Accessibility Implementation.
     override public function getChildIDArray():Array
     {
         var childIDs:Array = [];
     
         if (ListBase(master).dataProvider)
         {
             var n:uint = ListBase(master).dataProvider.length;
             for (var i:int = 0; i < n; i++)
             {
                 childIDs[i] = i + 1;
             }
         }
         return childIDs;
     }