お絵かきツールもどき
/**
* Copyright autumngoodluck ( http://wonderfl.net/user/autumngoodluck )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ApLF
*/
// forked from autumngoodluck's MyTemplate
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="25")]
public class DrawSample extends Sprite
{
private var _mouseDown:Boolean;
public function DrawSample()
{
_mouseDown = false;
alpha = 0.8;
graphics.moveTo(mouseX, mouseY);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true);
}
private function loop(event:Event):void
{
if (_mouseDown)
{
graphics.lineStyle(10, Math.random() * 0xFFFFFF);
graphics.lineTo(mouseX, mouseY);
}
else
{
graphics.moveTo(mouseX, mouseY);
}
}
private function mouseDownHandler(event:MouseEvent):void
{
_mouseDown = true;
}
private function mouseUpHandler(event:MouseEvent):void
{
_mouseDown = false;
}
}
}