1 Reply Latest reply on Jul 2, 2008 7:51 AM by matthew horn

    Glow filter

    milllcia@wp.pl
      I have a Rectangle :
      drawRoundRect(
      0, 0, w, h, radius,
      getStyle("borderColor"), 1);
      How can I add a outer Glow filter to this Rectangle ?
        • 1. Re: Glow filter
          matthew horn Level 3
          You add filters with the UIComponent's filters property; it takes an array (in this case, an array of 1).

          I borrowed the code from a few sites, but this should get you started:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          layout="vertical"
          verticalAlign="middle"
          backgroundColor="white"
          creationComplete="init()">

          <mx:Script>
          <![CDATA[
          import mx.styles.StyleManager;
          import mx.utils.*;
          import flash.filters.*;
          import flash.display.Graphics;
          import mx.core.UIComponent;

          private var fillColor:uint;
          private var aBox:Shape = new Shape();
          private var c:UIComponent = new UIComponent();

          private function init():void {
          aBox.graphics.lineStyle(3, 0x000000);
          aBox.graphics.beginFill(0xFFFFFF, 1);

          aBox.graphics.drawRect(100, 100, 100, 100);
          aBox.graphics.endFill();
          c.addChild(aBox);
          drawing_cvs.addChild(c);
          }

          private function addFilterToBox():void {
          var myFilters:Array = new Array();
          var filter:BitmapFilter = getBitmapFilter();
          myFilters.push(filter);
          filters = myFilters;
          c.filters = filters;
          }

          private function getBitmapFilter():BitmapFilter {
          var color:Number = 0x33CCFF;
          var alpha:Number = 0.8;
          var blurX:Number = 35;
          var blurY:Number = 35;
          var strength:Number = 2;
          var inner:Boolean = false;
          var knockout:Boolean = false;
          var quality:Number = BitmapFilterQuality.HIGH;

          return new GlowFilter(color,
          alpha,
          blurX,
          blurY,
          strength,
          quality,
          inner,
          knockout);
          }

          ]]>
          </mx:Script>

          <mx:HBox width="100%" height="100%">
          <mx:Canvas id="drawing_cvs" backgroundColor="#FFFFFF" width="500" height="500"/>
          <mx:Button label="Add Filter" click="addFilterToBox()"/>
          </mx:HBox>

          </mx:Application>

          hth,
          matt horn
          flex docs