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{
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application
xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute'' applicationComplete=''init();''%26gt;
%26lt;mx:Script%26gt;
%26lt;![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);
}
]]%26gt;
%26lt;/mx:Script%26gt;
%26lt;/mx:Application%26gt;
Thank you for your help
Drawing a shape dynamicallyI tried getting this working but had problems. Let me take a step back and ask what is your goal here. I'm just wondering if I can do things differently to achieve your goal.
Drawing a shape dynamicallyHi Greg.
My goal is to draw a small circle every time the client clicks on the stage, at that very point. Further, connect the points with a line, getting a polygonal shape.
Thanks. Madrid
No comments:
Post a Comment