问题
I have 2 frames and in frame 1 the target MC color is being changed to RED. After that i go to frame 2. If i came back to frame 1 the MC doesn't retain the RED color. What i do wrong. Please see the pictures. http://www.picz.ro/index.php?id=ec122060763b0fd744d2499882d4ae1f and http://www.picz.ro/index.php?id=00e207dfad35e7e414ed3236a1f79448
回答1:
eliminating frames, you can do it with code like this:
import flash.geom.ColorTransform;
import flash.events.MouseEvent;
var newColorTransform:ColorTransform;
var myMCTable:Array = [myMC1,myMC2,myMC3,myMC4,myMC5];
for (var i:int = 0; i < myMCTable.length; i++)
{
myMCTable[i].doubleClickEnabled = true;
myMCTable[i].addEventListener(MouseEvent.DOUBLE_CLICK, changeColor);
}
function changeColor(e:MouseEvent):void
{
newColorTransform = (e.target).transform.colorTransform;
newColorTransform.color = 0xFF0000;
(e.target).transform.colorTransform = newColorTransform;
}
prevNextBtn.txt.mouseEnabled = false;
prevNextBtn.addEventListener(MouseEvent.CLICK, prevNext);
function prevNext(e:MouseEvent):void
{
var i:int;
if (e.target.txt.text == "next")
{
e.target.txt.text = "prev";
for (i = 0; i < myMCTable.length; i++)
{
myMCTable[i].visible = false;
}
}
else
{
e.target.txt.text = "next";
for (i = 0; i < myMCTable.length; i++)
{
myMCTable[i].visible = true;
}
}
}
all that you need to change besides the code, is now you have just one button with a text field in it called "txt" and the label just changes
来源:https://stackoverflow.com/questions/8248404/movieclip-color-is-not-working-properly