7 Replies Latest reply on Jul 6, 2008 11:34 PM by milllcia@wp.pl

    PanelSkin

    milllcia@wp.pl
      In PanelSkin I draw a white background. I would like to add a GlowFilter on this shape, but I dont know how can I add this shape to stage.

      my code :

      private var shape: Shape;
      public function PanelSkin() {
      super();
      shape = new Shape();

      var glow:GlowFilter = new GlowFilter();
      glow.color = 0xff0000;
      glow.alpha = 0.8;
      glow.blurX = 4;
      glow.blurY = 4;
      glow.strength = 6;
      //glow.quality = BitmapFilterQuality.HIGH;
      shape.filters = [glow];
      }

      in function drawBackground(w:Number, h:Number):void { ...:
      shape.x = getStyle("borderThicknessLeft");
      shape.y = getStyle("headerHeight");
      shape.width = w-getStyle("borderThicknessLeft")-getStyle("borderThicknessRight");
      shape.height = h-getStyle("headerHeight")-borderThicknessBottom;

      shape.graphics.beginFill(0xff0000, getStyle("backgroundAlpha"));
      shape.graphics.drawRoundRectComplex( getStyle("borderThicknessLeft"), getStyle("headerHeight"),
      w-getStyle("borderThicknessLeft")-getStyle("borderThicknessRight"),
      h-getStyle("headerHeight")-borderThicknessBottom,
      radius, radius, radius, radius);
      shape.graphics.endFill();

      How to add my shape on stage ? yet it is not visible.




        • 1. Re: PanelSkin
          Gregory Lafrance Level 6
          You need to wrap your shape in a UIComponent, then add the UIComponent to the stage.

          var UIC:UIComponent = new UIComponent();
          UIC.addChild(shape);
          addChild(UIC);
          • 2. Re: PanelSkin
            milllcia@wp.pl Level 1
            All will be ok but a PanelSkin.as don`t have a difined method addChild:
            Error:
            1180: Call to a possibly undefined method addChild.

            What should I do ?

            • 3. Re: PanelSkin
              Gregory Lafrance Level 6
              Perhaps panel skin should extend Sprite?
              • 4. Re: PanelSkin
                milllcia@wp.pl Level 1
                I have change a code :
                private var shape:Sprite;

                public function PanelSkin() {
                super();
                shape = new Sprite();

                var glow:GlowFilter = new GlowFilter();
                glow.color = 0xff0000;
                glow.alpha = 0.8;
                glow.blurX = 4;
                glow.blurY = 4;
                glow.strength = 6;
                //glow.quality = BitmapFilterQuality.HIGH;
                shape.filters = [glow];

                var UIC:UIComponent = new UIComponent();
                UIC.addChild(shape);
                addChild(UIC);

                }
                but ist`s stlii the same problem. Call to a possibly undefined method addChild.
                If I change : public class PanelSkin extends HaloBorder {
                to : public class PanelSkin extends Sprite { he don`t see all the overriden method.
                • 5. Re: PanelSkin
                  milllcia@wp.pl Level 1
                  I made a mistake. It`s work ! thanks for answer :)
                  • 6. Re: PanelSkin
                    Gregory Lafrance Level 6
                    Please share your mistake with us, so we might also learn from it.
                    • 7. Re: PanelSkin
                      milllcia@wp.pl Level 1
                      public class PanelSkin extends HaloBorder {

                      private var shape:Sprite;
                      var UIC:UIComponent = new UIComponent();

                      public function PanelSkin() {
                      super();

                      shape = new Sprite();
                      var glow:GlowFilter = new GlowFilter();
                      glow.color = 0xff0000;
                      glow.alpha = 1;
                      glow.blurX = 5;
                      glow.blurY = 5;
                      glow.strength = 1;
                      glow.inner = false;
                      glow.quality = 2;
                      shape.filters = [glow];
                      graphics.clear();
                      UIC.addChild(shape);
                      }
                      .......
                      if (parent && hasPanelParent && !isAdded) {
                      parent.addChild(UIC);
                      isAdded = true;
                      }
                      shape.graphics.clear();
                      shape.graphics.beginFill(getStyle("backgroundColor"), getStyle("backgroundAlpha"));
                      shape.graphics.drawRoundRectComplex(borderThicknessLeft, headerHeight,
                      w-borderThicknessLeft-borderThicknessRight,
                      h-headerHeight-borderThicknessBottom,
                      radius, radius, radius, radius);
                      shape.graphics.endFill();