【问题标题】:Apply multiple filters, but not cascading (the following one over the preceding one in the filters array)应用多个过滤器,但不能级联(过滤器数组中的前一个过滤器)
【发布时间】:2014-07-07 13:27:35
【问题描述】:

我搜索了很多但没有成功,似乎没有人遇到过这个问题。 我有一个displayObject,我想在上面应用(例如)两个过滤器:假设两个dropShadowFilter,一个带有inner=true,另一个带有inner=false。 如文档中所述,过滤器按照它们在 filters 数组中出现的顺序应用。因此,如果您首先放置外部阴影滤镜,那么第二个滤镜也将应用于生成的阴影。 更改顺序并不是一个彻底的解决方案,问题仍然存在,并且应用不同的过滤器可以再次重现奇怪的效果。

我正在寻找一种方法来避免这种情况,即将过滤器全部应用于原始对象,而不是被任何其他过滤器修改

非常感谢。

下面的代码片段可用于进行一些快速测试。

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <s:DropShadowFilter id="dropShadowOuter"
                            inner="false"
                            distance="65"
                            color="#000000"
                            alpha="0.4"/>
        <s:DropShadowFilter id="dropShadowInner"
                            inner="true"
                            distance="9"
                            color="#f3f951"
                            alpha="1"/>
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.core.UIComponent;

            protected function applyFilters_clickHandler(event:MouseEvent):void
            {
                (OutIn.textDisplay as UIComponent).filters = [dropShadowOuter,dropShadowInner];
                (InOut.textDisplay as UIComponent).filters = [dropShadowInner,dropShadowOuter];
                (Out.textDisplay as UIComponent).filters = [dropShadowInner];
                (In.textDisplay as UIComponent).filters = [dropShadowOuter];
            }

        ]]>
    </fx:Script>

    <s:VGroup>
        <s:Button id="applyFilters" label="apply filters" click="applyFilters_clickHandler(event)"/>

    <s:TextArea id="OutIn" 
        text="EXAMPLE TEXT"
                width="600" height="200"
                fontFamily="Arial Black"
                fontSize="72"/>

        <s:TextArea id="InOut" text="EXAMPLE TEXT"
                width="600" height="200"
                fontFamily="Arial Black"
                fontSize="72"/>

        <s:TextArea  id="Out"
                     text="EXAMPLE TEXT"
                    width="600" height="200"
                    fontFamily="Arial Black"
                    fontSize="72"/>

        <s:TextArea  id="In"
                     text="EXAMPLE TEXT"
                    width="600" height="200"
                    fontFamily="Arial Black"
                    fontSize="72"/>



    </s:VGroup>


</s:Application>

【问题讨论】:

    标签: apache-flex filter effects dropshadow


    【解决方案1】:

    应用过滤器发生在您应用过滤器的当前位图数据上。因此,不可能通过一个 TextArea 和多个过滤器找到您的解决方案。 您可以尝试在每个 TextArea 上使用多个 TextArea 和一个过滤器,并将这些 textarea 与一个不错的混合模式重叠。

    <s:Group blendMode="multiply">
    
            <s:TextArea  id="Out"
                         alpha=".5"
                         filters="{[dropShadowOuter]}"
                         text="EXAMPLE TEXT"
                         width="600" height="200"
                         fontFamily="Arial Black"
                         fontSize="72"/>
            <s:TextArea  id="In"
                         alpha=".5"
                         filters="{[dropShadowInner]}"
                         text="EXAMPLE TEXT" 
                         width="600" height="200"
                         fontFamily="Arial Black"
                         fontSize="72"/>
        </s:Group>
    

    上面的这个例子不是你的解决方案,但可能会让你朝着正确的方向迈出一步。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-19
      • 1970-01-01
      • 2019-12-29
      • 1970-01-01
      • 2022-08-11
      • 1970-01-01
      相关资源
      最近更新 更多