Specifying accessible names for image buttons

Important Information about Techniques

See Understanding Techniques for WCAG Success Criteria for important information about the usage of these informative techniques and how they relate to the normative WCAG 2.1 success criteria. The Applicability section explains the scope of the technique, and the presence of techniques for a specific technology does not imply that the technology can be used in all situations to create content that meets WCAG 2.1.

Applicability

Note

Adobe has plans to stop updating and distributing the Flash Player at the end of 2020, and encourages authors interested in creating accessible web content to use HTML.

This technique relates to:

Description

For image based Button components the accessible name needs to be set to provide a functional label. This label indicates the button's function, but does not attempt to describe the image. The label is especially important if there are multiple buttons on the page that each lead to different results.

The accessible name for a button may need to be updated if the button changes during the use of the Flash movie.

Examples

Example 1: Accessible name for a simple image button

In this example, an icon based button is given an accessible name through scripting. When the button is clicked a web page is opened.

//provide text equivalent for image button
this.check_btn.accessibilityProperties = new AccessibilityProperties();
this.check_btn.accessibilityProperties.name = "Check page validation";

//set up event listener and function to navigate to URL

this.check_btn.addEventListener(MouseEvent.CLICK, onClickHandler);

function onClickHandler(e: MouseEvent): void {
  var btn = e.target;
  var url: String = "http://validator.w3.org";
  var request: URLRequest = new URLRequest(url);
  navigateToURL(request, '_blank');
}

The result is demonstrated in the working version of Accessible name for a simple image button. The source of Accessible name for a simple image button is available.

Example 2: Accessible name for a dynamic image button

import fl.controls.Button;
import fl.accessibility.ButtonAccImpl;

ButtonAccImpl.enableAccessibility();

var soundIsMuted = false;
var myButton: Button = new Button();
myButton.label = "";
myButton.x = myButton.y = 10;
myButton.width = myButton.height = 50;
updateAccName(myButton, "mute sound");
myButton.setStyle("icon", unmuted);
myButton.addEventListener(MouseEvent.CLICK, handleBtnClick);
addChild(myButton);

function handleBtnClick(e) {
  soundIsMuted = ! soundIsMuted;
  myButton.setStyle("icon", soundIsMuted? muted: unmuted);
  updateAccName(myButton, soundIsMuted? "unmute sound": "mute sound");
}

function updateAccName(obj, newName: String) {
  if (! obj.accessibilityProperties)
  obj.accessibilityProperties = new AccessibilityProperties();
  obj.accessibilityProperties.name = newName;
  if (Capabilities.hasAccessibility)
  Accessibility.updateProperties();
}

The result is demonstrated in the working version of Accessible name for a dynamic image button. The source of Accessible name for a dynamic image button is available.

Tests

Procedure

When a Flash Movie contains image based buttons, confirm that:

  1. An accessible name is provided for the button that describes the button's action
  2. If the button's action changes (for example when it is clicked) the accessible name changes correspondingly

Expected Results

  • #1 and #2 are true