Hello,
I am able to draw one rectangle at a time with mouse down and mouse
move but as soon as i start drawing one more the last one hides
out.This is because of the reason i am using Graphics.Clear().If I
remove the Graphics.clear() than strange shape comes while I move the
mouse to draw the rectangle-
private function setAnchor(e:MouseEvent):void{
if(!_dragging){
sprite.graphics.clear();
_corner = new Point(e.stageX, e.stageY);
_dragging = true;
stage.addEventListener(MouseEvent.MOUSE_MOVE, liveDrag);
}
}
private function completeRect(e:MouseEvent):void{
if(_dragging){
_dragging = false;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, liveDrag);
sprite.graphics.lineStyle(0, 0, 0);
sprite.graphics.beginFill(0x222222,0.30)
sprite.graphics.drawRect(_corner.x,
_corner.y, e.stageX -
_corner.x, e.stageY - _corner.y);
}
}
private function liveDrag(e:MouseEvent):void{
sprite.graphics.clear();
sprite.graphics.lineStyle(0, 0x999999);
sprite.graphics.drawRect(_corner.x, _corner.y,
e.stageX -
_corner.x, e.stageY - _corner.y);
sprite.removeEventListener(MouseEvent.MOUSE_UP,
completeRect);
addElement(sprite);
}
Please suggest how to draw multiple rectangles without hiding the last
one.
Thanks.
Abhilash
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.