KitchenSync v0.4

Contents

What is KitchenSync?

KitchenSync is an ActionScript 3.0 library for sequencing animations and other time-based actions.

KitchenSync was designed with developers in mind

KitchenSync was designed for developers who want a smart way to handle animation or other time-based functionality with code. Written from the ground up in ActionScript 3.0, KitchenSync relies on smart object-oriented architecture rather than complicated shorthand. It includes a number of features and shortcuts, such as the clone() method, that save effort for developers. KitchenSync makes extensive use of events and informative runtime errors and is quite flexible when it comes to extending the funcitonality.

The KitchenSync project is hosted on Google Code.

KitchenSync is more than an animation library

Tweens are a major part of KitchenSync but that is not the end. It also allows you to sequence sounds, functions, and event dispatches among other actions. The framework is open-ended allowing you to come up with new ways to work with the virtual timeline.

What are the goals of KitchenSync?

KitchenSync aims to...

How does it work?

KS uses an abstract class called AbstractSynchronizedAction as the base for all sequenceable events. These include (among other things) tweens, function calls, and event dispatches as well as groups of multiple actions. All synchronized actions share certain methods and properties such as duration and start() making them interchangeable and very easy to work with.

All action classes (including groups) inherit from the AbstractSynchronizedAction class.

Fig 1 - Overview of the synchronized action inheritance. All action classes (including groups) inherit from the AbstractSynchronizedAction class.

The Synchronizer

Behind the scenes, a class called Synchronizer acts as a timing clock for all of the synchronized action. Each time an action starts, the Synchronizer adds it to a sort of virtual timeline.

Sequencer assigns actions to a 'virtual timeline'.

Fig 2 - Sequencer assigns actions to a 'virtual timeline'.

Most synchronized actions have two properties that control time. They are duration and offset. The duration is the time during which the action executes. Some actions, such as functions and event dispatchers, have a duration of 0 meaning that they execute instantaneously and only once. The other property, offset, controls how much time will pass before the action will start to execute. Offset is synonymous with delay. Both properties start counting only after the action's start() method has been called.

Commonly Used Actions

Tween

Perhaps the most used action is the Tween. A tween is an object that represents a change of a property from one value to another over time. However, in most cases, the word tween is more likely to be synonymous with animation. A tween object has a target object (usually a display object) whose properties are affected, a target property, a duration, a start value and an end value. Tweens also use a special type of function, called an easing function, to determine the interpolation from the start to the ending values.

SynchronizedFunction

The SynchronizedFunction class represents a function or method and any specified arguments that are to be called at a specified time or after some delay. Just pass in the function you want to call and any arguments. The function will be called when the action executes.

Note that unlike earlier versions of ActionScript, with AS3 there is no need to use a delegate to retain the scope of the function.

SynchronizedDispatchEvent

An Event can be dispatched after a delay or as part of a sequence using a SynchronizedDispatchEvent object. Events are dispatched using the AS3 event dispatching system and can be sent from the SynchronizedDispatchEvent itself or from any other IEventDispatcher. The constructor can be passed either an Event object or a string for the event type.

SynchronizedSound

This class represents a sound that is to be played at a specified time or after some delay. The constructor will accept a Sound object, URLRequest object, or a URL as a string.

The Action Groups

The AbstractSynchronizedActionGroup class defines common characteristics of all action groups. All action groups use the addAction() method to add actions to the group. As you can see from Figure 1, AbstractSynchronizedActionGroup is itself a subclass of AbstractSynchronizedAction allowing you to nest action groups within other action groups or use a group as if it were a single action. This distinction makes creating long strings of time based events a relatively simple task.

Three types of Action Groups: Sequence, Parallel, and Staggered.

Fig 3 - Three types of Action Groups: Sequence, Parallel, and Staggered.

Sequence

In a Sequence group, actions are executed one after the other in order. Delays in between individual actions within the group are still maintained and will begin counting when the action's turn in the sequence comes up.

Parallel

With Parallel groups, all actions within the group are executed simultaneously. Although they all start at the same time, they may end at different times.

Staggered

A Staggered group of actions will execute one after the other in a sequence however, the actions are separated by a specified time (e.g. 1 second) rather than the end of the previous action.

Groups can be used in conjunction with one another. For example, you may wish to create a sequence that contains a parallel action so that you can have several actions occur at the same point in a sequence.

With all of the action groups, separate events are dispatched upon completion of individual items and of the entire group.

Downloads

The KitchenSync project is hosted on Google Code.