Welcome to:


ActionScript / Color Tween Classes /

Color Tween Classes 1.0

for Flash 8 and above

Perform advanced tweens on the tint or color transform of a movie clip with one line of code

These are ActionScript 2.0 classes derived from the builit-in Tween class (mx.transitions.Tween). The 'TweenRGB' class lets you perform a color tween on a movie clip (or any object), just as you would with the standard Tween class. It accepts numeric RGB values as the 'begin' and 'finish' parameters. The 'TweenColorTransform' class works the same way, except it tweens color transform objects instead of RGB values.

The Adobe documentation for the base class 'Tween' can be found here: Adobe Live Docs: Using the Tween class

  • Use these classes just like the base Tween class
  • Use all easing functions accepted by the Tween class
  • Can be used to apply color tweens to a filter object such as DropShadow


The 'TweenRGB' class:

The TweenRGB class allows you to create color tweens on movie clips or regular objects just as you would a motion tween using the Tween class. All you have to do is specify a movie clip as the 'obj' parameter, and then RGB values for the 'begin' and 'finish' parameters in the constructor of the TweenRGB, and it will automatically setup a tween that blends the color from 'begin' to 'finish'. The class also applies the new color to the movie clip via its colorTransform property.

// create a color tween on 'cherry_rgb'
import mx.transitions.TweenRGB;
import mx.transitions.easing.*;

var tween_rgb = new TweenRGB(
cherry_rgb,// movie clip to tween
"",// property to tween for non movie clips
Regular.easeInOut,// easing function
0xff0000,// start color
0x6600ff,// end color
3,// seconds duration
true);// use seconds for duration (false = use frames)


The 'TweenColorTransform' class:

The TweenColorTransform class allows you to tween ColorTransform objects and directly apply the result to movie clips or other objects, just as you would a motion tween using the Tween class. Specify a movie clip as the 'obj' parameter, and then ColorTransform objects for the 'begin' and 'finish' parameters in the constructor of the TweenColorTransform class. The class automatically sets up a tween that blends between these two transforms. The class also applies the new transform to the movie clip specified as the 'obj' (first parameter of the constructor).

// create a color tween on 'cherry_rgb'
import mx.transitions.TweenColorTransform;
import mx.transitions.easing.*;
import flash.geom.ColorTransform;

var tween_rgb = new TweenColorTransform(
cherry_ct,// movie clip to tween
"",// property to tween for non movie clips
Strong.easeInOut,// easing function
cherry_ct.transform. colorTransform,// start transform
new ColorTransform(1, 1, 1, 1, 0, 255, 255, 0),// end transform
1.5,// seconds duration
true);// use seconds for duration (false = use frames)







With this package you get:

  • TweenRGB and TweenColorTransform classes for Flash 8 and above
  • ColorTweenSample.fla sample file, which has the source for the demo shown above


Download


USAGE Import the mx.transitions.* package or create a class using the full class package name: myTween = new mx.transitions.TweenRGB();
HELP LOCATION This page.
SAMPLE FILES ColorTweenSample.zip contains a sample file and is bundled with the installation package; you will be prompted to save this file when installing the package.
SYSTEM REQS. windows apple marker Flash MX 2004; Windows or Mac
KEY WORDS color rgb tween class color transform colortransform