18
Creating Advanced Components
Making components accessible
A growing requirement for web content is that it should be accessible to people who have
disabilities. Visually impaired people can use the visual content in Flash applications by means of
screen reader software, which provides an audio description of the material on the screen.
When you create a component, you can include ActionScript that enables the component and a
screen reader to communicate. Then, when developers use your component to build an
application in Flash, they use the Accessibility panel to configure each component instance.
Flash MX 2004 includes the following accessibility features:
•
Custom focus navigation
•
Custom keyboard shortcuts
•
Screen-based documents and the screen authoring environment
•
An Accessibility class
To enable accessibility in your component, add the following line to your component’s class file:
mx.accessibility.
ComponentName
.enableAccessibility();
For example, the following line enables accessibility for the MyButton component:
mx.accessibility.MyButton.enableAccessibility();
When developers add the MyButton component to an application, they can use the Accessibility
panel to make it available to screen readers.
Adding versioning
When releasing components, you should define a version number. This lets developers know
whether they should upgrade, and helps with technical support issues. When you set a
component’s version number, use the static variable
version
, as the following example shows:
static var version:String = "1.0.0.42";
If you create many components as part of a component package, you can include the version
number in an external file. That way, you update the version number in only one place. For
example, the following code imports the contents of an external file that stores the version
number in one place:
#include "../myPackage/ComponentVersion.as"
The contents of the ComponentVersion.as file are identical to the previous variable declaration, as
the following example shows:
static var version:String = "1.0.0.42";
Best practices when designing a component
Use the following practices when you design a component:
•
Keep the file size as small as possible.
•
Make your component as reusable as possible by generalizing functionality.
•
Use the Border class rather than graphical elements to draw borders around objects.
•
Use tag-based skinning.
Summary of Contents for FLEX-CREATING ADVANCED COMPONENTS
Page 1: ...Creating Advanced Components...
Page 4: ...4 Contents...