Hi everyone.
I got trouble when I was trying to call getBounds() on a MovieClip with filter on it, This asset is made in Flash CS and is a flame shaped movie clip with several filters on each frame. when I call mc.getBounds(null) on this movieClip, the result rectangle I got is smaller than it should be, excluding outer glow filter's effect, (like getRect() method does), so my quesion is, can I use getBounds() method to get the boundary including filters, how? if not, any way else I can do this? Thank you in advance!
not a particularly elegate solution but this give you want you need
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xff0000);
sprite.graphics.drawRect(0, 0, 20, 20);
sprite.graphics.endFill();
var blurFilter:BlurFilter = new BlurFilter();
sprite.filters = [blurFilter];
addChild(sprite);
trace("sprite dim: ", sprite.getBounds(null));
var bmd:BitmapData = new BitmapData(sprite.width, sprite.height, true, 0);
trace("filter dim: " + bmd.generateFilterRect(sprite.getBounds(null), blurFilter));
Thank you very much.
For most cases, this article provides the method we need to get the correct boundary for clips with filter(s), that is great.
But in my case, I may not choose to do like this, because it sacrifice too much performance when the clip is nested, with children clips with or without filters, and filters on its own. Yes, sure I can calculate the actural boundary recursively(loop over all children and mark the max(min) value of the boundary), I still have serveral plans, do a little trick in Flash CS. But I will still seek for more effective way to solve this.
Thank you again, _spoboyle. realy helpful.
North America
Europe, Middle East and Africa
Asia Pacific