Basically for each frame (onEnterFrame), return a new colour so that over time the colour turns from red to green to blue to red... like a rainbow... a sequence of colours. The red, green, and blue Math.sin code above uses the correct multipliers I think to do this (the offset is not exactly correct (2 and 4) but good enough...
again.. all I need is a way to output the colour after the multipliers have altered the inputted colour, each frame.
Unless there is another way to do this such as with matrixes (which I again have no experience with).
Thanks.
edit: and when I mean output a colour I mean store the number for the colour in the 'colour' variable.
use:
class com.kglad.Color_AS2 {
// example usage:
/*
import com.kglad.Color_AS2;
import flash.geom.ColorTransform;
Color_AS2.colorChangeF();
var ct:ColorTransform = mc.transform.colorTransform;
this.onEnterFrame = function(){
ct.rgb = Color_AS2.colorF();
mc.transform.colorTransform = ct
}
*/
static var red:Object = new Object();
static var green:Object = new Object();
static var blue:Object = new Object();
static var colorValueA:Array = [15, 0, 128];
static var colorA:Array = [red, green, blue];
static var colorChangeA:Array = [1, -1];
static var primeA:Array = [3, 5, 7];
function Color_AS2() {
}
static function colorChangeF() {
for (var i:Number = 0; i < colorA.length; i++) {
colorA.val = Math.floor(Math.random() * 256);
colorA.colorChange = 2 * Math.round(Math.random()) - 1;
}
}
static function colorF(n:Number):Number {
if (!n) {
n = 0;
}
if (n % 2000 == 1) {
colorChangeF();
}
for (var i:Number = 0; i < colorA.length; i++) {
colorA.val += primeA * colorA.colorChange;
if (colorA.val > 255) {
colorA.val = 254;
colorA.colorChange *= -1;
} else if (colorA.val < 0) {
colorA.val = 1;
colorA.colorChange *= -1;
}
}
return colorA[0].val << 16 | colorA[1].val << 8 | colorA[2].val;
}
}