2 Replies Latest reply on Aug 13, 2009 9:37 PM by bendayan

    Drawing a shape dynamically

    bendayan

      I'm trying to draw small circles (as extended movie clip class), but instead, I get a black page in Flex.

      Can you help me to understand where am I wrong?

       

      Package code:

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      package

       

       

       

      import flash.display.MovieClip;

       

       

      import flash.events.MouseEvent;

       

       

       

      public class DrawingPoints extends MovieClip

      {

       

       

      private var mc1:MovieClip = new MovieClip();

       

       

      private var mc2:MovieClip = new MovieClip();

       

       

      private var mc3:MovieClip = new MovieClip();

       

       

      private var mc4:MovieClip = new MovieClip();

       

       

      private var mc5:MovieClip = new MovieClip();

       

       

       

      public function DrawingPoints()

      {

      stage.addEventListener(MouseEvent.CLICK, drawParticle);

      mc1.graphics.beginFill(0xFF0000);

      mc1.graphics.drawCircle(50, 50, 5));

       

       

      this.addChild(mc1);

       

       

      super();

      }

       

       

       

      public function drawParticle(e:MouseEvent)

      {

       

       

       

      mc2.graphics.beginFill(0xFF0000);

      mc2.graphics.drawCircle(50, 50, 4));

       

       

      this.addChild(mc2);

       

      mc3.graphics.beginFill(0xFF0000);

      mc3.graphics.drawCircle(50, 50, 3));

       

       

      this.addChild(mc3);

       

      mc4.graphics.beginFill(0xFF0000);

      mc4.graphics.drawCircle(50, 50, 2));

       

       

      this.addChild(mc4);

       

      mc5.graphics.beginFill(0xFF0000);

      mc5.graphics.drawCircle(50, 50, 1));

       

       

      this.addChild(mc5);

      }}}

       

      Mxml code:   // Here I have the feeling that my errors occur.

       

      com.myDomain

      {

       

       

       

       

       

       

       

       

       

       

       

       

       

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

      <mx:Application

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init();">

      <mx:Script>

      <![CDATA[

       

       

       

      import com.myDomain.DrawingPoints;

       

       

      import mx.graphics.*;

       

       

      import flash.events.IOErrorEvent;

       

       

      import flash.events.Event;

       

       

      import flash.display.*;

       

       

       

      public var particles:DrawingPoints = new DrawingPoints();

       

       

       

      public function init():void

      {

      DrawingPoints(particles);

      particle1 =

      new DrawingPoints();

       

       

      this.addChild(particles);

      }

      ]]>

      </mx:Script>

       

      </mx:Application>

       

      Thank you for your help