AS3 Custom Tween API

A few months ago I was experimenting with the new Tween classes available in ActionScript 3.0. After importing the Tween class from the new package I received the following error when I attempting to instantiate a Tween instance
ReferenceError: Error #1069: Property onTweenEnd not found on mx.controls.DataGrid

I found that this error would occur no matter what type of component I attempted to call a Tween on. This error I assume was being called on or during an interval call as it was firing constantly.

So after spending a decent amount of time going back and forth trying different things I simply decided it would be easier to write my own Tween API for AS3. My intentions were to simply provide a basic Tween API for an application that I was developing at work. all I wanted to do was have the ability to easily apply Tweens to a component in Flex 2. I wanted the tween to be simular to that which was available in ActionScript 2 under the mx.transitions packages.

The custom Tween API is easy to use and also very useful so I have decided to distribute it as an .swc file for other Flex Developers to use in their Flex 2.0 Projects.

The Tween API consists of 3 destinct classes:

  1. Tween – Public class which provides all Tween functionality
  2. TweenType – Static class which provides a simple set of public constants for providing Tween types
  3. TweenEffect – Internal Static class which provides all Tweening methods which are from Robert Penner’s Tweening equations

Usage is pretty straight forward. All you have to do is import the Tween and TweenType classes and instantiate an instance of the Tween class. The Tween class constructor excepts 6 parameters which are as follows:

  1. tweenTarget:DisplayObjectContainer,
  2. propertyToTween:String,
  3. tweenType:String,
  4. tweenStartPosition:Number,
  5. tweenStopPosition:Number,
  6. tweenDuration:Number

The second parameter, propertyToTween can be set by using a constant from the TweenType class. This class is useful and enables you to easily see what type of tweens are available via the list of public constants.

Future revisions will include a callback event handler which will fire once the Tween is completed. I will continue to post updates once they are completed.

You can download the Tween API (version 0.1.9) for AS3 by clicking here.

{Sorry, Comments are currently Closed! }