In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

自作の背景に絵を描きたい

Get Adobe Flash player
by Fumio 17 Aug 2011
    Embed
/**
 * 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);
        }
    }
}