1 Reply Latest reply on Jun 10, 2008 5:55 AM by matthew horn

    Nutty fills

    brmcc
      Greetings:

      I am confused by fill behavior. Specifically, I would have thought graphics.beginFill affects only what comes after it, but as the following code shows, this is not the case -- the call to beginFill adds fill to the upper-right area of the sprite:

      var sprite:Sprite = new Sprite();
      sprite.graphics.lineStyle(0,0x000000);
      sprite.graphics.lineTo(100,100);
      sprite.graphics.beginFill(0x112233);

      Can someone explain this?

      Here is the description of beginFill from the asdoc: "Specifies a simple one-color fill that subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) use when drawing."

      Here it is as a complete code file:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      creationComplete="initApp()">

      <mx:Script>
      <![CDATA[
      public function initApp():void
      {
      var sprite:Sprite = new Sprite();
      sprite.graphics.lineStyle(0,0x000000);
      sprite.graphics.lineTo(100,100);
      sprite.graphics.beginFill(0x112233);

      uic.addChild(sprite);
      }
      ]]>
      </mx:Script>

      <mx:UIComponent id="uic"/>
      </mx:Application>