Hi Carolyn,
I would say that it's because you are calling
graphics.moveTo
and
graphics.beginFill
during your loop, whereas it should be graphics.lineTo
Change your logic so that you do this (pseudo-code):
clear
lineStyle
moveTo - (starting point)
beginFill
loop {
lineTo - (each point)
}
moveTo - (optional end point)
endFill
Hope this helps.
Cheers,
Adam
----- Original Message -----
From: Carolyn Cole
To: [email protected]
Sent: Monday, April 02, 2007 11:52 PM
Subject: [flexcoders] Filled Polygon
Hello,
For some reason I can not seem to get my polygon created by lineto to fill.
The polygon gets drawn, but the fill never happens. Does anyone have any
suggestions?
The code I am using is bellow:
recColor = 0xFF0000;
transp=0.5;
var graphics:Graphics = recShape.graphics;
graphics.clear();
graphics.lineStyle(3,recColor,100);
graphics.beginFill(recColor,transp);
var lastPoint:Point = null;
for(var i:int=1; i< points.length; i++){
var p1:Point = new Point()
p1.x = points[i-1].x;
p1.y = points[i-1].y;
var p2:Point = new Point();
p2.x = points[i].x;
p2.y = points[i].y;
if (lastPoint == null){
graphics.moveTo(p1.x,p1.y);
graphics.beginFill(recColor,transp);
}
graphics.lineTo(p2.x, p2.y);
lastPoint = p2;
}
graphics.endFill();
Thanks!
-- Carolyn