DrawLine
Include mouse press event and EnterFrame event.
/**
* Copyright junsucom ( http://wonderfl.net/user/junsucom )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qZKL
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
private var m_bIsDown:Boolean;
private var m_uX:Number;
private var m_uY:Number;
public function FlashTest() {
m_bIsDown = false;
this.parent.stage.addEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
this.parent.stage.addEventListener(MouseEvent.MOUSE_UP, doMouseUp);
this.parent.stage.addEventListener(Event.ENTER_FRAME, doEnterFrame);
graphics.lineStyle(1, 0);
}
private function doMouseDown(evt:MouseEvent):void
{
m_bIsDown = true;
m_uX = mouseX;
m_uY = mouseY;
}
private function doMouseUp(evt:MouseEvent):void
{
m_bIsDown = false;
}
private function doEnterFrame(evt:Event):void
{
if (m_bIsDown)
{
graphics.moveTo(m_uX , m_uY);
m_uX = mouseX;
m_uY = mouseY;
graphics.lineTo(m_uX, m_uY);
}
}
}
}