I have a clip in my movie that changes colors randomly every timre it is loaded.
hers the code:
MovieClip.prototype.randomColor = function() {
var r = Math.floor(Math.random()*255)+1;
var g = Math.floor(Math.random()*255)+1;
var b = Math.floor(Math.random()*255)+1;
var c = new Color(this);
c.setRGB(r << 16 | g << 8 | b);
};
The problem is there are other movieclips I need to change to the same color.
Heres the script I’m trying to do:
to assign the color to multiple movieclips, just assign the random color to a variable and use that variable to apply colors… if you’re doing this more than once and all at once, then you can keep all the clips in an array and loop through that array to apply the color to each clip within.
_global.randomColor = 0xFFFFFF*Math.random();
coloredClips = [a_mc, b_mc, c_mc];
allSameColor = function() {
for (var i=0; 0<coloredClips.length; i++)
new Color(coloredClips*).setRGB(randomColor);
}