alphaOffset, alphaMultiplier, and _alpha

Can someone explain to me the relations between these properties?

I’m trying to do tween color transformation by ActionScript using devonair’script, but how to set the alphaOffset value so my animation tweening from 0 - 30 (_alpha value).

devonair script can be found here:

thanks

alphaOffset and alphaMultiplier are properties of the ColorTransform class whereas _alpha is a property of the movie clip class.

With the ColorTransform class, the ARGB offset and multiplier properties will modify each of the colour channels using the following equation:

newChannelValue = (oldChannelValue * channelMultiplier) + channelOffset

The _alpha property and the alphaMultiplier properties perform the exact same function in that they take the original value and take a percentage out of it to give you a new value. In fact, setting the _alpha property of a movie clip will directly change the *transform.colorTransform.alphaMultiplier *value of that movie clip. For instance given two movie clips, test1 and test2, the following will perform the exact same function on each:

//modifying test1:
import flash.geom.*;
var ct:ColorTransform = new ColorTransform();
ct.alphaMultiplier = .2;
ct.alphaOffset = 0;
test1.transform.colorTransform = ct;
//--
//modifying test2:
test2._alpha = 20;
//--

Now for your question, tweening the alpha value of a movie clip from 0 to 30. I would stick with the _alpha property as it avoids some extra/unnescary code for something so simple:

import mx.transitions.Tween;
import mx.transitions.easing.*;
var at:Tween = new Tween(mc, "_alpha", Regular.easeOut, 0, 30, 1, true);

But if you are bent on using the ColorTransform class, this will also work:

import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.geom.*;
var ct:ColorTransform = new ColorTransform();
var at:Tween = new Tween(ct, "alphaMultiplier", Regular.easeOut, 0, 0.3, 1, true);
at.onMotionChanged = function():Void  {
 mc.transform.colorTransform = ct;
};

Hope this helps :hoser:

thanks for your quick reply, I now clearly understand alphaMultiplier and _alpha. But i’m still a bit unsure about the alphaOffset one, what is its main purpose?
thanks

In that equation, it is the number that is added to the alpha channel after it has been multiplied by the alphaMultiplier.

For example, if we had the following values
currentAlpha = 100
alphaMultiplier = 0.08
alphaOffset = 120

And we plug those valuew sinto the equation we would get:
newAlpha = (currentAlpha * alphaMultiplier) + alphaOffset
newAlpha = (100 * 0.08) + 120
newAlpha = (8) + 120
newAlpha = 128

:cap:

So the newAlpha value in the equation will be ranging between -255 >> 255. right? not between 0 >> 100.:geek:
thanks for your quick help.

That is correct. Glad to help :hoser: