MC Tween: it saves the world.™

Home | Using MC Tween | Documentation | AS2 usage notes | Animation Types | Downloads | Examples | Extensions | Author & Disclaimer | Links

.colorTransformTo()

Applies To

MovieClip

Availability

Flash 6 and above, using AS1 or AS2.

Usage

<MovieClip>.colorTransformTo(ra, rb, ga, gb, ba, bb, aa, ab [, seconds, animation type, delay, callback, extra1, extra2]);
or
<MovieClip>.colorTransformTo(colorTransformObject [, seconds, animation type, delay, callback, extra1, extra2]);

Parameters

ra : Percentage desired for the R (red) color channel, usually from 0 to 100 (values from -1000 to 1000 are accepted). This parameter informs how much of the original channel will be maintained. The normal value for a static, non-colored MovieClip would be 100.

rb : The offset of tinting for the red channel, usually from 0 to 255 (values from -512 to 512 are accepted). This is added to the channel after the percentage transformation has taken place. The normal value for a static, non-colored MovieClip would be 0.

ga : Percentage desired for the G (green) color channel, usually from 0 to 100 (values from -1000 to 1000 are accepted). This parameter informs how much of the original channel will be maintained. The normal value for a static, non-colored MovieClip would be 100.

gb : The offset of tinting for the green channel, usually from 0 to 255 (values from -512 to 512 are accepted). This is added to the channel after the percentage transformation has taken place. The normal value for a static, non-colored MovieClip would be 0.

ba : Percentage desired for the B (blue) color channel, usually from 0 to 100 (values from -1000 to 1000 are accepted). This parameter informs how much of the original channel will be maintained. The normal value for a static, non-colored MovieClip would be 100.

bb : The offset of tinting for the blue channel, usually from 0 to 255 (values from -512 to 512 are accepted). This is added to the channel after the percentage transformation has taken place. The normal value for a static, non-colored MovieClip would be 0.

aa : Percentage desired for the A (alpha) channel, usually from 0 to 100 (values from -1000 to 1000 are accepted). This parameter informs how much opacity the object will have - it's just the same as the MovieClip's _alpha property, really. The normal value for a static, non-colored MovieClip would be 100.

ab : The offset opacity for the object's transparency. This is a bit tricky, but what it does is add more opacity when needed, even on areas where a MovieClip object is totally transparent. The normal value for a static, non-colored MovieClip would be 0.

colorTransformObject : This is a different way of doing the same thing. In this case, you can use color transformation objects (like you would with Color.setTransform()) to pass the parameters. The colorTransformObject would then be an object with properties called ra, rb, ga, gb, ba, bb, aa, and ab.

All other parameters are standard tween() related. Refer to the .tween() command for reference.

Also notice that all color parameters are optional - use undefined when a parameter has to be skipped. If a parameter value is not defined, it will not be tweened.

Returns

Nothing.

Description

Shortcut method; does a color transformation transition on a MovieClip object. While a bit confusing, the parameters used on this method are the equivalents of the attributes used on the native Color.setTransform() and allow for some powerful color transformation on MovieClips, including contrast and brightness controls.

The parameters used here are also directly related to the fields used on Flash's own "Advanced" color settings for a MovieClip.

Examples

// Creates a "dodge" look on a MovieClip in 2 seconds, using a "linear" transition
<MovieClip>.colorTransformTo(200, 0, 200, 0, 200, 0, undefined, undefined, 2, "linear");

// Tweens just the red channel of a MovieClip, in 0.6 seconds
<MovieClip>.colorTransformTo(200, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 0.6, "linear");

// Inverts the MovieClips color altogether, in 2 seconds
<MovieClip>.colorTransformTo(-100, 256, -100, 256, -100, 256, 100, 0, 2, "linear");

// Does an alpha transition on a MovieClip - this is equivalent to alphaTo(100, 1)
<MovieClip>.colorTransformTo(undefined, undefined, undefined, undefined, undefined, undefined, 100, undefined, 1);

// Resets a MovieClip to its normal state, on 0.5 seconds
<MovieClip>.colorTransformTo(100, 0, 100, 0, 100, 0, 100, 0, 0.5); // The same as above, but using a colorTransformObject myCTO = new Object(); myCTO.ra = 100; myCTO.rb = 0; myCTO.ga = 100; myCTO.gb = 0; myCTO.ba = 100; myCTO.bb = 0; myCTO.aa = 100; myCTO.ab = 0; <MovieClip>.colorTransformTo(myCTO, 0.5); // The same as above, but using an in-line colorTransformObject <MovieClip>.colorTransformTo({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0}, 0.5);

See Also

colorTo(), Color.setTransform()

MC Tween· Zeh Fernando, 2003-2006 · Proudly hosted at DreamHost · Disclaimer