- Home
- Tutorials
- Flash
- Intermediate
- Tint Animation, BindColor and RGBColor classes
Tint Animation, BindColor and RGBColor classes

RGBColor Class
In the RGBColor class you will find four propreties which will interact with the setter of each one a function that is called refreshColor will be called to update the display of the attached mc to the object IF non is attached nothing happens. Lets examine the class:
Class
import com.core.BindColor;
/**
* ...
* @author Amen Kamaleldine
*/
class com.core.RGBColor {
//Private Variables
private var _red:Number;
private var _green:Number;
private var _blue:Number;
private var _color:Number;
//currently attached MovieClip
private var mc:MovieClip;
/**
* Constructor
* @param red
* @param green
* @param blue
*/
public function RGBColor(red:Number,green:Number,blue:Number) {
this.red = (red==undefined)?0:red;
this.green = (green==undefined)?0:green;
this.blue = (blue==undefined)?0:blue;
}
/**
* gets the red value
*/
public function get red():Number { return _red; }
/**
* sets the red value
*/
public function set red(value:Number):Void {
_red = value;
//update the displayed color of the attached MC
refreshColor();
}
/**
* gets the green value
*/
public function get green():Number { return _green; }
/**
* sets the green value
*/
public function set green(value:Number):Void {
_green = value;
//update the displayed color of the attached MC
refreshColor();
}
/**
* gets the blue color
*/
public function get blue():Number { return _blue; }
/**
* sets the blue color
*/
public function set blue(value:Number):Void {
_blue = value;
refreshColor();
}
/**
* gets the color number of the attached Movie clip
*/
public function get color():Number {
_color=BindColor.getColorFrom(mc);
return _color;
}
/**
* sets the color of the attached movie clip
*/
public function set color(value:Number):Void {
_color = value;
var rgb:RGBColor = BindColor.colorToRGB(value);
this._red = rgb.red;
this._green = rgb.green;
this._blue = rgb.blue;
refreshColor();
}
/**
* attach the RGBColor object to a mc
* @param mc
*/
public function attachTo(mc:MovieClip) {
var rgb:RGBColor = BindColor.getRGBFrom(mc);
this._red = rgb.red;
this._green = rgb.green;
this._blue = rgb.blue;
this.mc = mc;
}
/**
//* bind the RGBColor object to a mc instance
* @param mc
*/
public function bindTo(mc:MovieClip) {
BindColor.bindColorTo(this, mc);
}
/**
* update the current color of the movieclip
*/
private function refreshColor() {
BindColor.bindColorTo(this, mc);
}
}
The class is well explained and it can be used directly to any movie clip instance
//declare an rgbColor object for the movieclip backgroun
var rgbColor:RGBColor = new RGBColor();
//attach it to the mc
rgbColor.attachTo(my_mc);
//and this to the text mc
rgbColor.red=255;
rgbColor.green=0;
rgbColor.blue=0;
//the MC will turn to Red
//or you can just call
rgbColor.color=0xFF0000;
On the Next page we will examine the BindColor Class.
