フィルタをいじっていて、加算するときはどうするのかと疑問が。例えば0〜30までblurをかけるときは、数値(下記の場合はval_x, val_y)を可変にして・・・
var filter:flash.filters.BlurFilter = new flash.filters.BlurFilter();
filter.blurX = val_x;
filter.blurY = val_y;
filter.quality = 1;
mc.filters = [filter];
mc.filters = [filter];
//ぼかし処理(加算)
function xAddFilter_blur(mc:MovieClip,val_x:Number,val_y:Number):void {
var array_filter:Array = mc.filters;
var exist_blur:Boolean = false;
var filter:flash.filters.BlurFilter;for (var i:int = 0; i<array_filter.length; i++) {
var wObj_filter:Object = array_filter[i];
if (wObj_filter is BlurFilter) {
exist_blur = true;
var current_blur:Number = isNaN(wObj_filter.blurX) ? 0:wObj_filter.blurX;
filter = new flash.filters.BlurFilter();
filter.blurX = current_blur + val_x;
filter.blurY = current_blur + val_y;
filter.quality = 1;array_filter.splice(i,1);
array_filter.push(filter);
mc.filters = array_filter;break;
}
}if (! exist_blur) {
filter = new flash.filters.BlurFilter();
filter.blurX = current_blur + val_x;
filter.blurY = current_blur + val_y;
filter.quality = 1;array_filter.push(filter);
mc.filters = array_filter;
}
}
if (wObj_filter is BlurFilter) {
あとは他のフィルタを上書きしないことと、BlurFilterがない(設定されていない)場合を考慮すればOK。