0 Replies Latest reply on Apr 9, 2010 11:19 AM by adamcrain

    basic graphical question (actionscript/flashbuilder)

    adamcrain

      I'm a totally newbie trying to create a library of graphical components that I can reuse in applications. I've created two projects in my workspace, one for the widgets and one for the application. When I draw the components onto the design screen, they now paint themselves as opposed to just being empty rectangles, great. They is something I'm missing however in the graphical heirarchy, b/c when I resize them they don't clear. Below is my class hierarchy:

       

      public class WidgetBase extends Canvas
          {
              public function WidgetBase()
              {
                  super();
              }
             
              override protected function commitProperties():void
              {
                  // The idea here is that since this is a graphical object, all of its properties are probably
                  // going to cause a redraw
                  this.invalidateDisplayList();
              }
                             
              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
              {                           
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
                  draw(unscaledWidth, unscaledHeight);           
              }
                     
             
              protected function draw(unscaledWidth:Number, unscaledHeight:Number):void
              {
                  graphics.clear();
              }
          }

       

      public class MyWidget extends WidgetBase
      {
                    
              public function BreakerWidget()
              {
                  super();
              }
                     
              protected override function draw(unscaledWidth:Number, unscaledHeight:Number):void
              {           
                  super.draw(unscaledWidth, unscaledHeight);           
                  graphics.beginFill(0xee0000, 0.9);
                  graphics.drawRect(1, 1, unscaledWidth-1, unscaledHeight-1);                       
              }
                     
      }

       

      What do I have to add to get MyWidget to clear properly?