Skip navigation
Currently Being Moderated

getBounds() method on DisplayObjects with filters

Apr 26, 2012 10:58 PM

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!

 
Replies
  • Currently Being Moderated
    Apr 27, 2012 1:26 AM   in reply to AndrewYuCWA1987

    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));
     
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2012 3:03 AM   in reply to AndrewYuCWA1987

    yes getBounds does exclude the filter effects

     

    you can get the filters by looping over the displayObjects.filters property, however without playing arround I wouldn't know how to handle this if there where several filters applied

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2012 3:16 AM   in reply to _spoboyle

    i found this which might help

     

    http://www.refactored.fr/?p=163

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points