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 keno42 08 Dec 2009
    Embed
/**
 * Copyright keno42 ( http://wonderfl.net/user/keno42 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/v6aZ
 */

package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.MouseEvent;
    public class FlashTest extends Sprite {
        private var bmpBg:BitmapData = new BitmapData(465,465,true,0);
        private var bmpCanvas:BitmapData = new BitmapData(465,465,true,0);
        private var spBg:Sprite = new Sprite;
        private var sp:Sprite = new Sprite;
        public function FlashTest() {
            // write as3 code here..
            addChild( new Bitmap(bmpBg) );
            addChild( spBg );
            addChild( new Bitmap(bmpCanvas) );
            addChild( sp );
            stage.addEventListener(MouseEvent.MOUSE_DOWN,onDown);
        }
        private function onDown(e:MouseEvent):void{
            spBg.graphics.lineStyle(25, 0x00FFFF);
            spBg.graphics.moveTo(e.stageX, e.stageY);
            sp.graphics.lineStyle(15, 0xFFFFFF);
            sp.graphics.moveTo(e.stageX, e.stageY);
            stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove);
            stage.addEventListener(MouseEvent.MOUSE_UP,onUp);
        }
        private function onMove(e:MouseEvent):void{ 
            spBg.graphics.lineTo(e.stageX, e.stageY);
            sp.graphics.lineTo(e.stageX, e.stageY);
        }
        private function onUp(e:MouseEvent):void{
            bmpBg.draw(spBg);
            bmpCanvas.draw(sp);
            spBg.graphics.clear();
            sp.graphics.clear();
            stage.removeEventListener(MouseEvent.MOUSE_MOVE,onMove);
            stage.removeEventListener(MouseEvent.MOUSE_UP,onUp);
        }
            
    }
}