当前位置:软件学习 > Flash >>

flash as3.0 改变影片剪辑的颜色方法总结

AS3.0 动态改变影片剪辑的颜色

 代码如下 复制代码

var a:ColorTransform = new ColorTransform();
a.color = 0x000000;
mc.transform.colorTransform = a;
stage.addChild(mc);

改变mc的颜色

ColorTransform () 构造函数

 代码如下 复制代码

public function ColorTransform(redMultiplier:Number = 1.0, greenMultiplier:Number = 1.0, blueMultiplier:Number = 1.0, alphaMultiplier:Number = 1.0, redOffset:Number = 0, greenOffset:Number = 0, blueOffset:Number = 0, alphaOffset:Number = 0)

方法二:
 

 代码如下 复制代码
var color:ColorTransform=new ColorTransform();
color.redMultiplier=0;
color.greenMultiplier=0;
color.blueMultiplier=0;
color.alphaMultiplier=0;
color.redOffset=255;
color.greenOffset=0;
color.blueOffset=255;
color.alphaOffset=255;
mc.transform.colorTransform=color;

 代码如下 复制代码

package {
    import flash.display.Sprite;
    import flash.display.GradientType;
    import flash.geom.ColorTransform;
    import flash.events.MouseEvent;

    public class ColorTransformExample extends Sprite {
        public function ColorTransformExample() {
            var target:Sprite = new Sprite();
            draw(target);
            addChild(target);
            target.useHandCursor = true;
            target.buttonMode = true;
            target.addEventListener(MouseEvent.CLICK, clickHandler)
        }
        public function draw(sprite:Sprite):void {
            var red:uint = 0xFF0000;
            var green:uint = 0x00FF00;
            var blue:uint = 0x0000FF;
            var size:Number = 100;
            sprite.graphics.beginGradientFill(GradientType.LINEAR, [red, blue, green], [1, 0.5, 1], [0, 200, 255]);
            sprite.graphics.drawRect(0, 0, 100, 100);
        }
        public function clickHandler(event:MouseEvent):void {
            var rOffset:Number = transform.colorTransform.redOffset + 25;
            var bOffset:Number = transform.colorTransform.redOffset - 25;
            this.transform.colorTransform = new ColorTransform(1, 1, 1, 1, rOffset, 0, bOffset, 0);
        }
    }
}

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,