Groups | Blog | Home
all groups > flash actionscript > december 2005 >

flash actionscript : Change MC color when xmouse increases.


Skatestick
12/24/2005 5:57:57 PM
Does anyone know how to graduately change the color of a movieclip when je move
to one side of the stage. What I mean is that when you move to the right slowly
with your mouse that the color of the movieclip slowly turns to a specific
color. Same thing when you move to the left.

Any ideas? Thanks.
kglad
12/25/2005 4:39:53 PM
the code below the dotted lines adds a function to your swf that fades a
movieclip from oldColor to newColor as the mouse moves from stage left to
right. to use, execute colorTransF(mc1, oldColor, newColor) where mc1 is the
movieclip to fade and the color variables are defined.



intermediateTF = new Array();
trA = ["ra", "rb", "ga", "gb", "ba", "bb", "aa", "ab"];
function colorTransF(mc, oldColor, newColor) {
co = new Color(mc);
co.setRGB(oldColor);
tf1 = co.getTransform();
co.setRGB(newColor);
tf2 = co.getTransform();
lo = new Object();
lo.onMouseMove = function() {
for (var ivar = 0; ivar<trA.length; ivar++) {
num =
Math.floor((tf2[trA[ivar]]*_xmouse/Stage.width+tf1[trA[ivar]]*(Stage.width-_xmou
se)/Stage.width));
intermediateTF[trA[ivar]] = num.toString();
}
co.setTransform(intermediateTF);
};
Mouse.addListener(lo);
}
AddThis Social Bookmark Button