AQColor
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Author: | Arthur Clemens |
| Classpath: | org.asapframework.util.actionqueue.AQColor |
| File last modified: | Thursday, 12 October 2006, 11:19:40 |
ActionQueue methods that control the color of a movieclip. Most methods call methods from org.asapframework.util.ColorUtils.
Summary
Class properties
- START_VALUE : Number
- Start animation value to be returned to the perform function.
- END_VALUE : Number
- End animation value to be returned to the perform function.
Class methods
- setColor (inMC:MovieClip, inHexColor:Object) : Void
- Set a movieclip's color to a color number (0xff3300) or string ("ff3300").
- setBaseColor (inMC:MovieClip, inBaseColor:Object, inShouldSetColor:Boolean) : Void
- Stores a color variable as "base color" property in the movieclip that can be referenced by setToBaseColor and mixColors.
- restoreColor (inMC:MovieClip) : Void
- Restores the true color of the movieclip, making it appear as in the Library.
- setToBaseColor (inMC:MovieClip) : Void
- Sets the color of a movieclip (back) to the color value stored in its base color.
- mixColors (inMC:MovieClip, inDuration:Number, inStartColor:Object, inMixColor:Object, inPercentage:Number, inComponentPercentage:Number, inEffect:Function) : ActionQueuePerformData
- Sets the color of a movieclip over a period of time by mixing two colors.
- mixTransforms (inMC:MovieClip, inDuration:Number, inStartTransform:Object, inMixTransform:Object, inEffect:Function) : ActionQueuePerformData
- Sets the color of a movieclip over a period of time by mixing two colors, using two color transform objects, which gives greater control over the transparency of the color effect over time.
Class properties
END_VALUE
static private END_VALUE:Number = 1
(read)
End animation value to be returned to the perform function.
START_VALUE
static private START_VALUE:Number = 0
(read)
Start animation value to be returned to the perform function.
Class methods
mixColors
static function mixColors (
inMC:MovieClip,
inDuration:Number,
inStartColor:Object,
inMixColor:Object,
inPercentage:Number,
inComponentPercentage:Number,
inEffect:Function) : ActionQueuePerformData
Sets the color of a movieclip over a period of time by mixing two colors.
Parameters:
inMC :
movieclip to set the color of
inDuration :
length of animation in seconds; 0 is used for perpetual animations - use -1 for instant change
inStartColor :
the start color; either: 1) a hexadecimal number (like 0xff0033 or -0xff0033) or hex string ("ff0033" of "-ff0033") or 2) the string "base": the base color that is set with setBaseColor.
inMixColor :
the color to mix in; either: 1) a hexadecimal number or 2) the string "base"
inPercentage :
(optional) the amount of color of inMixColor that is mixed in baseColor; value between 0.0 and 1.0. A percentage of 0.5 with baseColor red and inMixColor yellow will result in orange; a percentage of 1.0 in yellow; default value is 1.0
inComponentPercentage:
(optional) the percentage value used for ra, ga, ba and aa; default 0 is assumed; use 100 to retain the transparency of pictures; use values greater than 100 for light effects
inEffect :
(optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list.
Returns:
- A new ActionQueuePerformData object.
Example:
- To mix two colors over a period of 1 second, use:
queue.addAction( AQColor.mixColors, my_mc, 1, 0xff0000, 0xffff00 );The following code sets a movieclip to yellow, and adds a white tint on rollover:ColorUtils.setBaseColor(my_mc, 0xffd633, true); // 'true' sets the color immediately ... my_mc.onRollOver = function () { var queue:ActionQueue = new ActionQueue(); queue.addAction( AQColor.mixColors, this, 1, null, 0xffffff, 0.5 ); queue.run(); }
To animate the movieclip back to its original Library color, use a black color with a component percentage of 100:queue.addAction( AQColor.mixColors, this, 1, null, 0x000000, 1.0, 100 );
Implementation note:
- Colors are mixed using Color.setTransform.
mixTransforms
static function mixTransforms (
inMC:MovieClip,
inDuration:Number,
inStartTransform:Object,
inMixTransform:Object,
inEffect:Function) : ActionQueuePerformData
Sets the color of a movieclip over a period of time by mixing two colors, using two color transform objects, which gives greater control over the transparency of the color effect over time.
Parameters:
inMC :
movieclip to set the color of
inDuration :
length of animation in seconds
inStartTransform:
start color (color transformation object); use org.asapframework.util.ColorUtils.getTransformObject to create a color transform object from a hex number
inMixTransform :
mix color (color transformation object)
inEffect :
(optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list.
Returns:
- The return value of AQWorker.returnValue.
Example:
- This example mixes two colors, created with org.asapframework.util.ColorUtils.getTransformObject, over a period of 1 second:
var t1:Object = ColorUtils.getTransformObject(0x0066ff); var t2:Object = ColorUtils.getTransformObject(0x660000); queue.addAction( AQColor.mixTransforms, my_mc, 1, t1, t2 );
Use 0x000000 to give the movieclip its original color. The following code transforms the current color back to the original color over a period of 1 second:var t2:Object = ColorUtils.getTransformObject(0x000000); queue.addAction( AQColor.mixTransforms, my_mc, 1, null, t2 );
Implementation note:
restoreColor
static function restoreColor (
inMC:MovieClip) : Void
Restores the true color of the movieclip, making it appear as in the Library.
Parameters:
inMC:
movieclip to set the default color of
Example:
- The following code first sets the movieclip color to red, then restores it again:
queue.addAction( AQColor.setColor, clip_mc, 0xff0000 ); queue.addAction( AQColor.restoreColor, clip_mc );
Implementation note:
setBaseColor
static function setBaseColor (
inMC:MovieClip,
inBaseColor:Object,
inShouldSetColor:Boolean) : Void
Stores a color variable as "base color" property in the movieclip that can be referenced by setToBaseColor and mixColors.
Use a base color when you plan to change the color of the movieclip, and you want to revert or animate back to the original set color. For instance, mixColors allows to use the base color (using the string "base") as end color.
To retrieve the set base color, call org.asapframework.util.ColorUtils.getBaseColor.
Use a base color when you plan to change the color of the movieclip, and you want to revert or animate back to the original set color. For instance, mixColors allows to use the base color (using the string "base") as end color.
To retrieve the set base color, call org.asapframework.util.ColorUtils.getBaseColor.
Parameters:
inMC :
movieclip that will store the property
inBaseColor :
a color hex number (like 0xff3300) or hex string ("ff3300")
inShouldSetColor:
(optional) if true the movieclip's color is set using setRGB(baseColorNum); default is false (no color change)
Implementation note:
setColor
static function setColor (
inMC:MovieClip,
inHexColor:Object) : Void
Set a movieclip's color to a color number (0xff3300) or string ("ff3300").
Parameters:
inMC :
the movieclip to set the color of
inHexColor:
hexadecimal number (0xff3300) or string ("ff3300") of the new color; you can use negative hex numbers as well: (-0xff3300 or "-ff3300")
Example:
- This example makes a movieclip red:
queue.addAction( AQColor.setColor, clip_mc, 0xff0000 );
THe following line makes it yellow:queue.addAction( AQColor.setColor, clip_mc, "ffff00" );
Implementation note:
setToBaseColor
static function setToBaseColor (
inMC:MovieClip) : Void
Sets the color of a movieclip (back) to the color value stored in its base color.
Parameters:
inMC:
movieclip to set the color of
Implementation note: