这么说吧,AS3中Color类并没有抹掉,在fl.motion包内你依然可以找到它;
Color类继承自ColorTransform类,而ColorTransform继承自Object类;所以ColorTransform比Color更底层;
然而要想应用颜色变化于显示对象上,就一定要对显示对象的transform.colorTransform属性指定;
比如你一样可以这样用:
import fl.motion.Color;
var color:Color=new Color();
color.color=0x00ff00;
_sprite.transform.colorTransform=color;
Color增加了控制亮度和色调等功能,其实ColorTransform满足大部分功能了,更复杂的还有ColorMatrixFilter呢
ps:I'm a beginner,just my opinion.
------------------------------------
package{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
public class AsProject extends Sprite{
private var _sprite:Sprite;
private var color:ColorTransform;
public function AsProject(){
_sprite=new Sprite();
_sprite.graphics.beginFill(0xff0000);
_sprite.graphics.drawCircle(10,10,10);
_sprite.graphics.endFill();
addChild(_sprite);
color=_sprite.transform.colorTransform;
_sprite.addEventListener(MouseEvent.CLICK,onClick);
}
private function onClick(e:MouseEvent):void{
var color24:Number=0x00 << 16 | Math.random()*0xff << 8 | 0x00;
color.color=color24;
trace(color24.toString(16));
e.currentTarget.transform.colorTransform=color;
}
}
}
----------------------------
var color:ColorTransform=_mc.transform.colorTransform;
chanceColor(color);
_mc.transform.colorTransform=color;//_mc 你的影片剪辑
function chanceColor(c:ColorTransform){
var n:Number=Math.random();
if(n<.3) c.redOffset=255;
else if(n<.6) c.greenOffset=255;
else{
c.redOffset=255;
c.greenOffset=255;
}
}