AS 1.0 Color Fader - Done

Just though of posting this. Enjoy! See the sample FLA below. You may see this effect in some websites.

//------------------------------------------
// COLOR FADER 1.0 by [COLOR=RoyalBlue]blackjersey
[COLOR=Black]// if (numofsleepinaweek = 0) {
// colorsbegintofade = true;
// }
// nonsense. [/COLOR]
[/COLOR]//------------------------------------------

[COLOR=Black]// Place this function in a keyframe at the start of your movie:

function colourFade(r, g, b) {
oldColour = myColour.getRGB().toString(16);
newColour = “0x”+r+g+b;
oldR = oldColour.substr(0, 2);
oldR = “0x0000”+oldR;
oldR = parseInt(oldR);
oldG = oldColour.substr(2, 2);
oldG = “0x0000”+oldG;
oldG = parseInt(oldG);
oldB = oldColour.substr(4, 2);
oldB = “0x0000”+oldB;
oldB = parseInt(oldB);
newR = newColour.substr(2, 2);
newR = “0x0000”+newR;
newR = parseInt(newR);
newG = newColour.substr(4, 2);
newG = “0x0000”+newG;
newG = parseInt(newG);
newB = newColour.substr(6, 2);
newB = “0x0000”+newB;
newB = parseInt(newB);
i = 0;
_root.complete = false;
_root.newColourArray = new Array();
while (!_root.complete) {
if (newR>oldR) {
oldR += 1;
}
if (newR<oldR) {
oldR -= 1;
}
if (newR == oldR) {
oldR = newR;
}
if (newG>oldG) {
oldG += 1;
}
if (newG<oldG) {
oldG -= 1;
}
if (newG == oldG) {
oldG = newG;
}
if (newB>oldB) {
oldB += 1;
}
if (newB<oldB) {
oldB -= 1;
}
if (newB == oldB) {
oldB = newB;
}
hexR = (oldR).toString(16);
hexG = (oldG).toString(16);
hexB = (oldB).toString(16);
_root.newColourArray* = “0x”+hexR+hexG+hexB;
i++;
if (newR == oldR && newG == oldG && newB == oldB) {
_root.complete = true;
_root.begin = 0;
}
}
}

// Then attach this script to the MC that you want to change colour (in my example I gave the MC an instance name “box”

onClipEvent (enterFrame) {
if (_root.complete=true) {
limit = _root.newColourArray.length;
myColour = new Color(_root.box);
if (_root.begin<limit) {
myColour.setRGB(_root.newColourArray[_root.begin]);
_root.begin += 5;
}
if (_root.begin>=(limit-1)) {
_root.complete = false;
}
}
}

// In the key frame where you placed the MC “box” put the following script:

_root.complete = false;
myColour = new Color(_root.box);
myColour.setRGB(“0xebeced”);

// For you to change the color of “box” call the command:

_root.colourFade(“b3”,“d7”,“16”);

Please take note:

[COLOR=RoyalBlue]_root.begin += 1;[/COLOR]

If you change this to :

[COLOR=RoyalBlue]_root.begin += 2;[/COLOR] //or higher…

color change perform the transition twice as fast.

[/COLOR]