11 Replies Latest reply on Aug 19, 2009 1:46 AM by Nishant28

    Problem with drawing a new Shape in Flex

    bendayan Level 1

      Hi There!

       

      I'm new at Flex and AS3 (don't laugh at me). I have a problem trying to draw a shape. The Alert fires, but the shape doesn't display. Looking for help.

       

      The code:

       

       

       

       

       

       

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="drawTrapecio();"

      >

      <mx:Script>

      <![CDATA[

       

       

       

       

      import mx.graphics.*;

       

       

       

       

       

       

      import flash.display.*;

       

       

      import mx.controls.Alert;

       

       

       

       

       

      public function drawTrapecio():void

      {

      Alert.show("Test");

       

       

      var trapecio:Shape = new Shape;

       

      // eventually, I replace Sprite for Shape, like this: var trapecio:Sprite = new Sprite, to no avail.

      trapecio.graphics.lineStyle(5, 0x000000);

      trapecio.graphics.moveTo(100, 100);

      trapecio.graphics.lineTo(200, 50);

      trapecio.graphics.lineTo(200, 350);

      trapecio.graphics.lineTo(50, 400);

       

       

      this.addChild(trapecio);

      }

      ]]>

      </mx:Script>

      </mx:Application>

       

      I really appreciate any help you can give.

      Madrid