自作の背景に絵を描きたい
/**
* Copyright Fumio ( http://wonderfl.net/user/Fumio )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iV0F
*/
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
public class Test extends Sprite {
private var bg_mc:Sprite = new Sprite();
public function Test() {
addChild(bg_mc);
bg_mc.graphics.beginFill(0x0, 0);
bg_mc.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
bg_mc.graphics.endFill();
graphics.lineStyle(1, 0x0);
bg_mc.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
bg_mc.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
}
private function MouseDown(event:MouseEvent):void {
graphics.moveTo(mouseX, mouseY);
bg_mc.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}
private function MouseUp(event:MouseEvent):void {
bg_mc.removeEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}
private function MouseMove(event:MouseEvent):void {
graphics.lineTo(mouseX, mouseY);
}
}
}