应用过滤器的一切在AS3 [英] Apply Filter to Everything in AS3

查看:128
本文介绍了应用过滤器的一切在AS3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个过滤器在AS3 / Flex的SDK。我可以添加一个过滤器就好了任何一个单独的对象 - 但我想过滤器应用到的所有的是某个对象的子

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 certain object.

想暂停窗口弹出,并暂停窗口下方一切都模糊了。

Think a pause window pops up, and everything below the pause window goes blurry.

应用一个过滤器,每个单独的对象(例如:通过列表迭代)。不工作,从每一个对象过滤器就可以重叠,看看pretty的丑陋

Applying a filter to each individual object (eg: iterating through a list) doesn't work, as the filters from each object can then overlap and look pretty ugly.

有谁知道如何去这样做?有没有一种方法来应用过滤器的所有的?

Does anyone know how to go about doing this? Is there a way to apply a filter to everything?

下面是的code的简化版本:

Here's a simplified version of the code:

myCanvas.graphics.beginFill(0x00FF00,0.5);
myCanvas.graphics.drawRect(0,0,100,100);
myCanvas.addChild(new vectorImage());
myCanvas.addChild(new vectorImage2());
var blur:BlurFilter = new BlurFilter();
myCanvas.filters = [blur];

无论是直接绘制的图形,也没有孩子得到应用的模糊效果。我试着改变默认设置并尝试其他的过滤器:

Neither the directly-drawn graphics nor the children get the blur effect applied. I've tried altering the defaults and tried other filters:

var colors:Array = [0xEDEDED, 0xCCCCCC, 0x211b28, 0x211b28, 0x211b28];
var alphas:Array = [0, 1, .35, .5, 1];
var ratios:Array = [0, 50, 100, 115, 155];  			
myCanvas.filters = [new GradientGlowFilter(0, 0, colors, alphas, ratios, 50, 50, 1, 3, "full", false)];

使用相同的效果(即:无)。什么工作是:

With identical effects (that is to say: none). What DOES work, is:

var vi:MovieClip = new vectorImage();
myCanvas.addChild(vi);
vi.filters = [blur];

,但产生了上述问题与多个过滤器不对准正确

but produces the above mentioned problems with multiple filters not aligning properly.

推荐答案

在我看来,你有两种可能的方法:

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.

打造舞台的大小的BitmapData(或者你想模糊的部分),绘制阶段,在applyFilter,将其添加到显示列表(在一切之上),以及关于该附加顶部不应该模糊所有的精灵(我想一个警告框或类似)。请注意,您应该更新的BitmapData上调整大小。

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.

更新: 您的code似乎是正确的,但我不熟悉Flex,所以也许你可以不加过滤器,帆布(它是一个DisplayObject?)......可能他设置cacheAsBitmap设置为假工作(这是相当马车有时) ......无论如何,这样的事情应该做的伎俩:

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...

干杯......

这篇关于应用过滤器的一切在AS3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆