Movieclip color is not working properly? [duplicate]

瘦欲@ 提交于 2020-01-17 01:13:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!