What's wrong with this function?


MovieClip.prototype.nc = function(){
	Math.round( Math.random()*0xFFFFFF );
	myColoredObject = new Color (this);
	myColoredObject.setRGB(myColor);
}

then i call the function by placing an action on the mc that says:


onClipEvent(enterFrame){
	nc();
}

pssst… you never defined the variable myColor :wink:

lmao

genius beta … pure genius

right so now the code looks like this:


MovieClip.prototype.nc = function(){
	myColor = Math.round( Math.random()*0xFFFFFF );
	myColoredObject = new Color (this);
	myColoredObject.setRGB(myColor);
}

and it’s going skitzo … i’m guessing it’s b/c i tell the mc to do it on (enterFrame) but wheew … it’s changing color 15 times a second … lol

if i do on (load) then it will only set one color … i’d kinda like a transition … i don’t remember the code but a while back there was a code posted here for a random color that tweened itself from one color to the next.

do you remember what it was?

Try this…

MovieClip.prototype.nc = function() {
	red = Math.sin(ra += .02)*127+128;
	green = Math.sin(rb += .05)*127+128;
	blue = Math.sin(rc += .09)*127+128;
	myCol = red << 16 | green << 8 | blue;
	myColored = new Color(this);
	myColored.setRGB(myCol);
};

wonderful

ty

No problem…