Revision: 47064
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 31, 2011 17:16 by adrianparr
Initial Code
function traceFilters(displayObject:DisplayObject):void{ if(!displayObject || !displayObject.filters || displayObject.filters.length == 0) return trace('No filters found.'); var s:String = ''; var formatHexNumber:Function = function(i:uint = 0):String{ if(isNaN(i)) return '0x000000'; var s:String = i.toString(16); while(s.length < 6) s = '0' + s; return '0x' + s.toUpperCase(); } for(var i:int = 0; i < displayObject.filters.length; ++i){ if(displayObject.filters[i] == null) continue; var f:Object = displayObject.filters[i]; if(i > 0) s += '\n'; if(displayObject.filters.length > 1) s += '\t'; var qcn:String = getQualifiedClassName(f); 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 + ')'; if(qcn == 'flash.filters::BlurFilter') s += 'new BlurFilter(' + f.blurX + ', ' + f.blurY + ', ' + f.quality + ')'; 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)) }) + '])'; 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 + ')'; 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 + ')'; 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 + ')'; 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 + ')'; 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 + ')'; if(i + 1 < displayObject.filters.length) s += ',' } trace(displayObject.name + '.filters = [' + s + ' ];'); }
Initial URL
http://www.calypso88.com/?p=610
Initial Description
All credit for this goes to Rob at calypso88.
Initial Title
AS3 Trace Out Filters Applied to a DisplayObject
Initial Tags
list, filter
Initial Language
ActionScript 3