Travels

Thursday, March 6, 2008

Making games accessible

Recently I've been making some games I've been working on accessible to the mobility and vision impaired to satisfy 508 compliance. This usually involves setting up tabIndex attributes and adding tags that screen readers can pick up.

Here's a quick overview for adding accessibility using AS2

Adding tabIndex is easy; just write:
someObject.tabIndex = 3;
to change it simply reassign the tabIndex a new value

Adding alt tags for screenreaders requires a little bit more code;
someObject._accProps = new Object();
someObject._accProps.name = "Text for the screen reader";
Accessibility.updateProperties();

The last line updates the alt text; so if you want to change the alt text after setting it once:
someObject._accProps.name = "Next alt text";
Accessibility.updateProperties();

That's about it, not too hard but the key is to test it out. Tabbing is easy enough you can test it straight from Flash, just make sure the Control>>Disable Keyboard Shortcuts is turned off

Testing the alt tags is trickier. You'll need screenreading software. I use a demo version of Windows Eyes. JAWS has also been recommended to me.
The demo only lasts about 30 min every time you open it, so I have it in a virtual machine which I restart whenever I need without rebooting my computer.

So far I've found one bug with tabbing. If you have tabbed onto an object and then set its ._visible = false; the tabbing order (sometimes) will skip ahead of the expected next object. I did some testing and so far I've found that if you use unloadMovie instead of _visible there is no problem.

FYI if you remove an object that you are currently tabbed to, the expected result of removing it or making it's tabindex = undefined is that the next object will be the one with the lowest tabIndex (the first object in the tabbing list).

To remove tabbing from an object:
someObject.tabIndex = undefined;

To stop alt text from being read by a screen reader, either
someObject._accProps.name = "";
Accessibility.updateProperties();

or

someObject._accProps._silent = true;

Here are some techniques I use for controlling accessibility:

I make variables to act as switches for tabbing and screen reader accessibility.

The tabbing var I set to false, then if tab is pushed I switch it to true.
The screen reader var I set to false and then set to true using Accessibility.isActive();

I usually set the screen reader switch within a keypress handler or some other function that runs soon after the movie is loaded. I do this because if you check Accessibility.isActive(); first thing, you may get a false negative.


Here are some useful links for reading up on Flash accessibility:
AS2:
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001895.html
(try the white paper below for a better list)

AS3:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/accessibility/AccessibilityProperties.html

For a good source of accessibility answers for Flash check out:
http://www.adobe.com/accessibility/

The white paper by Bob Regan is an excellent read for getting a better understanding of what accessibility means and how to make Flash accessible.

No comments: