2 Replies Latest reply on Aug 28, 2010 12:36 PM by Francisc

    Black and White Filter

    Francisc Level 3

      Hello!

       

      Is there anyway to apply a black and white filter over all the elements of a Group in Flex 4, please?

        • 1. Re: Black and White Filter
          ShardulSingh Level 3

          Hi,

          below is the solution for you problem.Origionally all spark componets are having their label and text in red color.

          But when you added these three lines inside the spark group all the elements becomes Black and White.

          <s:filters>
                          <s:ColorMatrixFilter id="cmf" matrix="{bwMatrix}" />

          </s:filters>

           

          So If you want to see them in origional color then comment these three lines.

          Hope you will like it. Let me know if you have any issue.Below is code.

           

           

           

           

           

           

           

           

          <?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:Script>

           

                  <![CDATA[

           

                      private var r:Number = 0.2225;

           

                      private var g:Number = 0.7169;

           

                      private var b:Number = 0.0606;

           

           

           

                      [Bindable]

           

                      private var bwMatrix:Array = [r, g, b, 0, 0,

           

                          r, g, b, 0, 0,

           

                          r, g, b, 0, 0,

           

                          0, 0, 0, 1, 0];

           

                  ]]>

           

              </fx:Script>

           

           

           

              <fx:Declarations>

           

                  <!-- Place non-visual elements (e.g., services, value objects) here -->

           

              </fx:Declarations>

           

           

           

           

           

           

           

          <mx:VBox width="800" height="600" borderStyle="solid" horizontalAlign="center" verticalAlign="middle">

           

                  <s:Group>

           

                      <s:filters>

           

                          <s:ColorMatrixFilter id="cmf" matrix="{bwMatrix}" />

           

                      </s:filters>

           

                          <s:VGroup>

           

                              <s:Label text="Spark Label" color="0xFF0000"/>   

           

                              <s:Button label="Spark button" color="0xFF0000"/>

           

                              <s:TextArea text="Text area of spark" color="0xFF0000"/>

           

                          </s:VGroup>

           

                      </s:Group>

           

          </mx:VBox>       

           

          </s:Application>

           

           

           

           

           

          with Regards,

           

          Shardul Singh Bartwal

          • 2. Re: Black and White Filter
            Francisc Level 3

            Thanks!