Hey gang. I’m making a thing where I need the color of several different things to change gradually and dynamically (on certain item clicks).
I setRGB so I can the getTransform to subsequently color.rb +=, so I can transition the colors fine. My “problem” is that i’m trying to develop it as a function so I can simply call the function for each item that needs to color change rather than repeating the same code a bunch of times for each item.
I tried making a Color.prototype, no luck, I tried making a MovieClip.prototype, no luck. I basically need a way to pass the color of an item to a function and then onEnterFrame it into changing. So function? Prototype? Something else?
oldColor = grass_color.getTransform();
//to get starting colors
arby = oldColor.rb;
gebe = arby;
bebe = gebe;
//Grayscale transition so R G and B all the same
n = 30+Math.round(Math.random()*30);
//random number of frames (between 1 and 2 seconds at 30FPS);
c = Math.round(Math.random()*100);
//new target color;
i = 0;
changer = holder.createEmptyMovieClip("changer", 1);
changer.onEnterFrame = function() {
if (i<n) {
i++;
oldColor.rb -= (arby-c)/n;
oldColor.gb -= (gebe-c)/n;
oldColor.bb -= (bebe-c)/n;
grass_color.setTransform(oldColor);
} else {
removeMovieClip(this);