0 Replies Latest reply on Apr 16, 2007 3:29 AM by faisy78

    Unexpected behavior with Graphics Methods

    faisy78
      I am building some custom components that utilize graphics methods for vector drawing. In one of the component I do some drawing in the following order.

      1. Draw a Line
      2. Create a Color Filled Circle
      3. Draw a Line

      The problem is that the circle filling is distorted by the first line.
      However, If I draw both the lines either before or after drawing the color filled Circle, everything appears fine.

      To illustrate the issue, here is a simplified component code, and a sample Application using that component

      ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////
      ///////////////////////// Test Component Code /////////////////////////////////////////
      ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////

      package Test
      {
      import mx.core.UIComponent;

      public class TestComponent extends UIComponent
      {
      protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
      {
      super.updateDisplayList(unscaledWidth, unscaledHeight);
      graphics.clear();
      graphics.lineStyle(1, 0x000000, 1);

      graphics.moveTo(unscaledWidth * 0.5, unscaledHeight * (-0.5));
      graphics.lineTo(unscaledWidth * 0.5, unscaledHeight * 1.5);

      graphics.beginFill(0x007700, 1);
      graphics.drawCircle(unscaledWidth * 0.5, unscaledHeight * 0.5, unscaledWidth * 0.5);
      graphics.endFill();

      graphics.moveTo(unscaledWidth * (-0.5), unscaledHeight * 0.5);
      graphics.lineTo(unscaledWidth * 1.5, unscaledHeight * 0.5);
      }
      }
      }

      ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////
      ///////////////////////// Test Application //////////////////////////////////////////////////////
      ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:Test="Test.*">
      <Test:TestComponent x="200" y="200" width="200" height="200" />
      </mx:Application>