/** * 設定物件亮度 * @param obj 物件實體 * @param value 亮度值,value取值範圍 -1 ~ 1,對應Flash内容制作工具裡的 -100% ~ 100%! */ private function setBrightness(obj:DisplayObject , value:Number):void { var colorTransformer:ColorTransform = obj.transform.colorTransform; var backup_filters:* = obj.filters; if (value >= 0) { colorTransformer.blueMultiplier = 1 - value; colorTransformer.redMultiplier = 1 - value; colorTransformer.greenMultiplier = 1 - value; colorTransformer.redOffset = 255 * value; colorTransformer.greenOffset = 255 * value; colorTransformer.blueOffset = 255 * value; } else { value = Math.abs(value) colorTransformer.blueMultiplier = 1 - value; colorTransformer.redMultiplier = 1 - value; colorTransformer.greenMultiplier = 1 - value; colorTransformer.redOffset = 0; colorTransformer.greenOffset = 0; colorTransformer.blueOffset = 0; } obj.transform.colorTransform = colorTransformer; obj.filters = backup_filters; }
2012年12月3日 星期一
[Flash AS3] 設定物件亮度
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言