应用于DisplayObject的AS3跟踪过滤器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了应用于DisplayObject的AS3跟踪过滤器相关的知识,希望对你有一定的参考价值。

All credit for this goes to Rob at calypso88.
  1. function traceFilters(displayObject:DisplayObject):void{
  2. if(!displayObject || !displayObject.filters || displayObject.filters.length == 0) return trace('No filters found.');
  3. var s:String = '';
  4.  
  5. var formatHexNumber:Function = function(i:uint = 0):String{
  6. if(isNaN(i)) return '0x000000';
  7. var s:String = i.toString(16);
  8. while(s.length < 6) s = '0' + s;
  9. return '0x' + s.toUpperCase();
  10. }
  11.  
  12. for(var i:int = 0; i < displayObject.filters.length; ++i){
  13. if(displayObject.filters[i] == null) continue;
  14. var f:Object = displayObject.filters[i];
  15. if(i > 0) s += ' ';
  16. if(displayObject.filters.length > 1) s += ' ';
  17. var qcn:String = getQualifiedClassName(f);
  18. if(qcn == 'flash.filters::BevelFilter') s += 'new BevelFilter(' + f.distance + ', ' + f.angle.toFixed(3) + ', ' + formatHexNumber(f.highlightColor) + ', ' + f.highlightAlpha + ', ' + formatHexNumber(f.shadowColor) + ', ' + f.shadowAlpha + ', ' + f.blurX + ', ' + f.blurY + ', ' + f.strength + ', ' + f.quality + ', "' + f.type + '", ' + f.knockout + ')';
  19. if(qcn == 'flash.filters::BlurFilter') s += 'new BlurFilter(' + f.blurX + ', ' + f.blurY + ', ' + f.quality + ')';
  20. if(qcn == 'flash.filters::ColorMatrixFilter') s += 'new ColorMatrixFilter([' + f.matrix.map(function(element:*, index:int, arr:Array):String{ return (int(element) == element) ? String(element) : String(Number(element).toFixed(3)) }) + '])';
  21. if(qcn == 'flash.filters::ConvolutionFilter') s += 'new ConvolutionFilter(' + f.matrixX + ', ' + f.matrixY + ', [' + f.matrix.map(function(element:*, index:int, arr:Array):String{ return (int(element) == element) ? String(element) : String(Number(element).toFixed(3)) }) + '], ' + f.divisor + ', ' + f.bias + ', ' + f.preserveAlpha + ', ' + f.clamp + ', ' + formatHexNumber(f.color) + ', ' + f.alpha + ')';
  22. if(qcn == 'flash.filters::DropShadowFilter') s += 'new DropShadowFilter(' + f.distance + ', ' + f.angle.toFixed(3) + ', ' + formatHexNumber(f.color) + ', ' + f.alpha + ', ' + f.blurX + ', ' + f.blurY + ', ' + f.strength + ', ' + f.quality + ', ' + f.inner + ', ' + f.knockout + ', ' + f.hideObject + ')';
  23. if(qcn == 'flash.filters::GlowFilter') s += 'new GlowFilter(' + formatHexNumber(f.color) + ', ' + f.alpha + ', ' + f.blurX + ', ' + f.blurY + ', ' + f.strength + ', ' + f.quality + ', ' + f.inner + ', ' + f.knockout + ')';
  24. if(qcn == 'flash.filters::GradientBevelFilter') s += 'new GradientBevelFilter(' + f.distance + ', ' + f.angle.toFixed(3) + ', [' + f.colors.map(function(element:*, index:int, arr:Array):String{ return formatHexNumber(element as uint) }) + '], [' + f.alphas + '], ' + '[' + f.ratios + '], ' + f.blurX + ', ' + f.blurY + ', ' + f.strength + ', ' + f.quality + ', "' + f.type + '", ' + f.knockout + ')';
  25. if(qcn == 'flash.filters::GradientGlowFilter') s += 'new GradientGlowFilter(' + f.distance + ', ' + f.angle.toFixed(3) + ', [' + f.colors.map(function(element:*, index:int, arr:Array):String{ return formatHexNumber(element as uint) }) + '], [' + f.alphas + '], ' + '[' + f.ratios + '], ' + f.blurX + ', ' + f.blurY + ', ' + f.strength + ', ' + f.quality + ', "' + f.type + '", ' + f.knockout + ')';
  26. if(i + 1 < displayObject.filters.length) s += ','
  27. }
  28. trace(displayObject.name + '.filters = [' + s + ' ];');
  29. }

以上是关于应用于DisplayObject的AS3跟踪过滤器的主要内容,如果未能解决你的问题,请参考以下文章

AS3使一个显示对象相对于另一个显示对象居中

AS3将DisplayObject转换为黑白

ActionScript 3 AS3将DisplayObject转换为黑白

ActionScript 3 AS3使用ColorTransform设置DisplayObject的颜色

ActionScript 3 AS3将DisplayObject调整为Rectangle

ActionScript 3 带有Masked DisplayObject的AS3 bitmapData.draw()