Apply Filter to Everything in AS3

后端 未结 1 1132
我在风中等你
我在风中等你 2021-01-26 13:50

I\'m trying to add a filter in AS3/Flex SDK. I can add a filter just fine to any one single object - but I want to apply the filter to everything that is a child of a c

相关标签:
1条回答
  • 2021-01-26 14:01

    As I see it, you have two possible approaches:

    • put everthing you want to blur in a separate container as the rest and apply the filters to that container.

    • create a BitmapData of the size of the stage (or the part you want to blur), draw the stage, applyFilter, add it to the the display list (on top of everything) and on top of that add all sprites that shouldn't be blurred (I imagine an alert box or similar). Note that you should update the BitmapData on resize.

    UPDATE: Your code seems correct, but I'm not familiar with Flex, so maybe you can't add filters to Canvas (is it a DisplayObject?)... maybe setting his cacheAsBitmap to false works (it's quite buggy sometimes)... anyway, something like this should do the trick:

    var container=new Sprite();
    myCanvas.addChild(container);
    container.addChild(new vectorImage());
    container.addChild(new vectorImage2());
    container.filters=[blur];
    

    or maybe Canvas has a container property already...

    Cheers...

    0 讨论(0)
提交回复
热议问题