cleanup sketch class

This commit is contained in:
Jeremy Penner 2011-05-03 22:27:18 -07:00
parent a0028fbea0
commit 4046a7eab6

View file

@ -33,10 +33,16 @@ package
private function init(e: Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.doubleClickEnabled = true;
addEventListener(Event.REMOVED_FROM_STAGE, cleanup);
stage.addEventListener(MouseEvent.CLICK, onClick);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
private function cleanup(e: Event):void
{
removeEventListener(Event.REMOVED_FROM_STAGE, cleanup);
stage.removeEventListener(MouseEvent.CLICK, onClick);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
public function clear():void
{
rgpoint = [];
@ -76,13 +82,13 @@ package
}
private function redrawShape():void
{
ClickArea.drawShape(shape, rgpoint, 0x555555, 0x000000, 0.1);
ClickArea.drawShape(shape, rgpoint, 0x555555, 0xb8860b, 0.1);
}
private function redrawLine(ptEnd:Point):void
{
var ptStart:Point = rgpoint[rgpoint.length - 1];
shapeLine.graphics.clear();
shapeLine.graphics.lineStyle(1);
shapeLine.graphics.lineStyle(1, 0xb8860b);
shapeLine.graphics.moveTo(ptStart.x, ptStart.y);
shapeLine.graphics.lineTo(ptEnd.x, ptEnd.y);
}