Accessibility

Table of Contents

Using timeline labels to dispatch events with the ActionScript 3.0 TimelineWatcher class

The TimelineWatcher and TimelineEvent classes

The TimelineWatcher class is a small, simple utility class. Here is the full documentation:


Public methods

Events

Event Object Type: com.refunk.events.TimelineEvent
Event.type property: com.refunk.events.TimelineEvent.LABEL_REACHED
Custom property/value: currentFrame: The current frame (int)
currentLabel: The current timeline label (String)
Event Object Type: com.refunk.events.TimelineEvent
Event.type property: com.refunk.events.TimelineEvent.END_REACHED
Custom property/value: currentFrame: The current frame (int)
currentLabel: The current timeline label (String)

Because the TimelineWatcher class extends the built-in EventDispatcher class you can add event listeners using the standard addEventListener() method. It goes hand-in-hand with the TimelineEvent class, which is a custom event class that explicitly types the events used by TimelineWatcher. These events additionally store the current frame number and label, so they can be retrieved via the event object.

You can find the TimelineWatcher and TimelineEvent classes in the sample file for this article (timelinewatcher.zip). Both classes are made available as free code by Refunk and are distributed under the GNU General Public License.