Techniques for WCAG 2.0

Skip to Content (Press Enter)

This document is a draft, and is designed to show changes from a previous version. It is presently showing added text,changed text,deleted text,[start]/[end] markers,and Issue Numbers.

Hide All Edits   |   Toggle Deletions  |   Toggle Issue Numbers   |   Toggle [start]/[end] Markers   |   Show All Edits

Changes are displayed as follows:

-

FLASH14: Using redundant keyboard and mouse event handlers in Flash

Applicability

This technique relates to:

User Agent and Assistive Technology Support Notes

See User Agent Support for Flash for general information on user agent support.

Description

The objective of this technique is to demonstrate how to provide device independence by providing equivalent event handlers in response to a mouse or focus event. Supporting both mouse and keyboard events ensures that users will be able to perceive the same information, regardless of the input device they used. If the event changes the state of the control, it may be important to change the descriptive name of the control in the event handlers.

Examples

Example 1: Updating button text with multiple event handlers

In this example, a group of buttons is assigned the same event handlers for the flash.events.FocusEvent.FOCUS_IN and flash.events.MouseEvent.MOUSE_OVER events. When a button receives focus or is hovered over using a mouse, text describing the button will be updated.

Example Code:

import fl.accessibility.ButtonAccImpl;
import fl.controls.Button;
import flash.accessibility. *
import flash.events.FocusEvent;
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;

ButtonAccImpl.enableAccessibility();
var states: Object = {
  "Alabama": "Alabama is a state located in the southeastern region of the \
    United States of America.",
  "California": "California is the most populous state in the United States",
  "New York": "New York is a state in the Mid-Atlantic and Northeastern \
    regions of the United States"
};

var buttons: Array =[];
var button: Button;
var accProps: AccessibilityProperties;
var count = 0;
for (var i in states) {
  button = new Button();
  button.label = i;
  button.addEventListener(MouseEvent.CLICK, clickHandler);
  button.addEventListener(MouseEvent.MOUSE_OVER, highlightHandler);
  button.addEventListener(MouseEvent.MOUSE_OUT, unHighlightHandler);
  button.addEventListener(FocusEvent.FOCUS_IN, highlightHandler);
  button.addEventListener(FocusEvent.FOCUS_OUT, unHighlightHandler);
  accProps = new AccessibilityProperties();
  accProps.description = states[i];
  button.accessibilityProperties = accProps;
  addChild(button);
  button.x = 30
  button.y = 30 + count * 30;
  buttons[i] = button;
  count++;
}

function highlightHandler(e) {
  descText.text = states[e.target.label];
}

function unHighlightHandler(e) {
  descText.text = "";
}


function clickHandler(e) {
  var url: URLRequest = new URLRequest("http://www.wikipedia.org/wiki/" + e.target.label);
  navigateToURL(url, "_self");
}

Note: To improve accessibility for screen reader users, the descriptive text is also attached to the buttons themselves as an accessible description. Also note that for button components, the MouseEvent.CLICK event will fire on mouse clicks as well as when the Enter key is pressed.

This technique is illustrated in the working version of Updating button text with multiple event handlers. The working version of Updating button text with multiple event handlers is available.

Tests

Procedure

For all scripted event handlers in a Flash Movie,

  1. Confirm that event handlers are assigned for both mouse and keyboard events

Expected Results