AS3补间变色

时间:2011-03-30 07:17:48

标签: actionscript-3

我在运行时加载了这个名为cHolder的movieclip。我首先应用一个色调,当它是mouseOver时,将没有色调。如何应用补间以使色调更改逐渐显示?谢谢!

        var imageLoader = new Loader();
        imageLoader.load(new URLRequest(projectDP));        
        var origColor: Color = new Color();
        origColor.setTint( 0x000000, 0.8 );
        cv.cHolder.transform.colorTransform = origColor;
        cv.cHolder.addChild(imageLoader);
        this.addChild(cv);


        cv.cHolder.addEventListener(MouseEvent.MOUSE_OVER, onRoll);
        cv.cHolder.addEventListener(MouseEvent.MOUSE_OUT, onOut);
            function onRoll(e:Event):void
        {
            origColor.setTint( 0, 0 );
            e.currentTarget.transform.colorTransform = origColor;
        }           

            function onOut(e:Event):void
        {

            origColor.setTint( 0x000000, 0.8 );
            e.currentTarget.transform.colorTransform = origColor;
        }

1 个答案:

答案 0 :(得分:3)

我建议使用补间引擎。您可以使用Flash Tween,但我更喜欢使用任何可用的引擎,例如TweenMax

补间色彩,你会做这样的事情:

import com.greensock.*;
import com.greensock.plugins.*;
TweenPlugin.activate([TintPlugin]);

var color:uint = 0x0;
var imageLoader = new Loader();
    imageLoader.load(new URLRequest(projectDP));        
    var origColor: Color = new Color();
    origColor.setTint( 0x000000, 0.8 );
    cv.cHolder.transform.colorTransform = origColor;
    cv.cHolder.addChild(imageLoader);
    this.addChild(cv);


    cv.cHolder.addEventListener(MouseEvent.MOUSE_OVER, onRoll);
    cv.cHolder.addEventListener(MouseEvent.MOUSE_OUT, onOut);
        function onRoll(e:Event):void
    {
        //origColor.setTint( 0, 0 );
        //e.currentTarget.transform.colorTransform = origColor;
        TweenLite.to(e.currentTarget, 1, {tint:null});
    }           

        function onOut(e:Event):void
    {

        //origColor.setTint( 0x000000, 0.8 );
        //e.currentTarget.transform.colorTransform = origColor;
        TweenLite.to(e.currentTarget, 1, {tint:0x000000});          
    }