Recipe 23.1. Detecting and Redirecting Users with Assistive Devices


Problem

You want to determine whether a user is accessing the movie with an assistive device so that you can redirect the user to a resource optimized for accessibility.

Solution

Use Accessibility.isActive( ) and System.capabilities.hasAccessibility to determine whether the Flash player is communicating with a screen reader.

Discussion

Testing whether the computer supports accessibility is necessary, because Flash can communicate to a screen reader only through Microsoft Active Accessibility, which is supported only in Internet Explorer for Windows. It is not presently supported in any other browser or the standalone player. You can test for this case using System.capabilities.hasAccessibility, a property that returns true when the player supports accessibility. In other words, this test always returns TRue in Internet Explorer for Windows and false in all other browsers.

In addition to testing whether the player supports accessibility, you also need to test whether an assistive technology (generally a screen reader) is communicating with Flash Player. You can do this using Accessibility.isActive( ). The following Action-Script code tests whether the user appears to be using an assistive technology:

 if (System.capabilities.hasAccessibility && Accessibility.isActive()) {   // Flash Player is communicating with an assistive technology. } 

Assistive technologies take time to connect to the Flash Playerup to a secondand if the Player executes the test the moment it loads, it is likely to return false regardless of whether an assistive technology is present. Therefore, it's frequently helpful to use setInterval( ) to test for an assistive technology for a few seconds. The following script does just that:

 var nAccessibilityInterval:Number = setInterval(this, "testAccessibility", 100);  var nStartTimer:Number = getTimer(); function testAccessibility():Void {   if (Accessibility.isActive() && System.capabilities.hasAccessibility) {      clearInterval(nAccessibilityInterval);      this.gotoAndPlay("accessible"); // Or another   redirection action } else if(getTimer() - nStartTimer > 2000) {   clearInterval(nAccessibilityInterval);   this.gotoAndPlay("standard"); } } 

Although this script is likely to detect when assistive technologies are present, it is not foolproof. For example, the user could be using a technology that Flash does not detect. In addition to this script, you should consider employing an accessibility link in an obvious location in your site. When users select that link, they go directly to the accessible version, and they don't have to rely on this accessibility detection script.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net