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

flash on 2010-2-1

参考 http://casualplay.net/blog/2005/11/flash_copypixels_1.html
Get Adobe Flash player
by hacker_cobulht0 01 Feb 2010
package {
	//参考 http://casualplay.net/blog/2005/11/flash_copypixels_1.html
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.events.*;
	import flash.display.GradientType;
	import flash.geom.Point;
	import flash.geom.Matrix;
	import flash.net.URLRequest;
	import flash.display.Loader;
	[SWF(width = "465", height = "465", backgroundColor = 0xFEE1B7, frameRate = "60")]
	public class rakugaki2 extends Sprite {
		private var now_tool:String="brush";
    	private var bg:Sprite;
		private var loader0:Loader;
		private var loader:Loader;
		
	public function rakugaki2() {
		//背景----------------------------------------------------------------------------------------------------
		var bg:back_ground=new back_ground();
		addChildAt(bg,0);
		//各ボタン----------------------------------------------------------------------------------------------------
		var btimg1:pencils =new pencils();addChild(btimg1);
		var btimg2:erasers =new erasers();addChild(btimg2);
		btimg1.x=btimg2.x=26;btimg2.y=40;btimg1.rotation=btimg2.rotation=40;
		
		var btPeint:buttons=new buttons();
		var btEraze:buttons=new buttons();
		addChild(btPeint);
		addChild(btEraze);
		btPeint.y=0;
		btEraze.y=40;
		btPeint.addEventListener(MouseEvent.MOUSE_UP,function(e){now_tool="brush";});
		btEraze.addEventListener(MouseEvent.MOUSE_UP,function(e){now_tool="eraser";});		
		init();
	}
	
	//----------------------------------------------------------------------------------------------------
	private function init(){
		// --- ビットマップ作成
		var layer:BitmapData = new BitmapData(465, 465, true, 0);
		var circle:Sprite = new blush_image();
		var brush_shape:BitmapData = new BitmapData(circle.width*2, circle.height*2, true, 0x0);
		brush_shape.draw(circle);
		
		var brush_src:BitmapData = new BitmapData(500, 500, true, 0xFF12356);	
		
		var stage1:MovieClip = new MovieClip();
		addChildAt(stage1,1);
		stage1.addChild(new Bitmap(layer));
		
		var brimg:MovieClip = new MovieClip();
		addChild(brimg);
		brimg.addChild(new Bitmap(brush_shape));		
		
		// --- 消しゴム作成
		var eraser_shape:BitmapData = new BitmapData(brush_shape.width, brush_shape.height, true, 0xFFFFFFFF);
		eraser_shape.draw(brimg);
		eraser_shape.copyChannel(eraser_shape,eraser_shape.rect, new Point(0, 0), 1, 8);
		removeChild(brimg);
		
		// --- ブラシを使う		
		function useBrush():void {
			var offset:Point = new Point(stage1.mouseX-brush_shape.width/2, stage1.mouseY-brush_shape.height/2);
			layer.copyPixels(brush_src, brush_src.rect, offset, brush_shape, new Point(0, 0), true);
		}	
		
		// --- 消しゴムを使う
		function useEraser():void {
			var offset:Point = new Point(stage1.mouseX-eraser_shape.width/2, stage1.mouseY-eraser_shape.height/2);
			layer.copyPixels(layer,layer.rect, offset, eraser_shape, new Point(0, 0), false);
		}
		
		stage1.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
		function mouseDownHandler():void {
					if (stage1.hitTestPoint(mouseX, mouseY, true)) {
					switch (now_tool) {
					case "brush": 
					stage1.addEventListener(MouseEvent.MOUSE_MOVE,useBrush);
					break;						
					case "eraser":
					stage1.addEventListener(MouseEvent.MOUSE_MOVE,useEraser);
					break;
					}
					}
		}
		
		stage1.addEventListener(MouseEvent.MOUSE_UP,function(e){			
			switch (now_tool) {
					case "brush": 
					stage1.removeEventListener(MouseEvent.MOUSE_MOVE,useBrush);
					break;
					case "eraser":
					stage1.removeEventListener(MouseEvent.MOUSE_MOVE,useEraser);
					break;
			}
			stage1.removeEventListener(MouseEvent.MOUSE_UP,mouseDownHandler);
		});
	}
	
	
    }
}


import flash.display.*;
import flash.filters.BlurFilter;
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
import flash.display.GradientType; 
import flash.geom.Matrix;

class buttons extends SimpleButton{
    function buttons(){
		this.hitTestState = (function():Sprite{
            var s:Sprite = new Sprite();
            s.graphics.beginFill(0x222222);
            s.graphics.drawRect(0, 0, 50, 40);      
            return s;
        })();
}}
class blush_image extends Sprite{
    function blush_image(){
            graphics.beginFill(0x222222);
            graphics.drawCircle(15,15,6);      
            filters = [ new BlurFilter( 12,12,1) ] ;	
}}
class pencils extends Sprite{
public function pencils(){
		graphics.beginFill (0xFFDA8C, 1);
		graphics.moveTo (9, 0);
		graphics.lineTo (0, 11);
		graphics.lineTo (18, 11);
		graphics.endFill ();
		var gbm:Matrix = new Matrix(); 
		gbm.createGradientBox(18, 20, 0, 0, 0); 
		graphics.beginGradientFill(GradientType.LINEAR, [0x72AA00,0x336633], [1,1], [100,255], gbm); 
		graphics.drawRoundRect(0,10, 18,20,4);
		graphics.endFill();
		 graphics.beginFill (0x444444, 1);
		 graphics.drawRoundRect(7,0,4,4,2);
		 graphics.endFill ();
		filters = [ new DropShadowFilter(4, 45, 0xFF7268, 1, 10, 10, 1, 3, false, false, false ) ] ;	
	}
}
class erasers extends Sprite{
public function erasers(){	
		var gbm:Matrix = new Matrix(); 
		var rot:Number = 2 * Math.PI * (90 / 360);
		gbm.createGradientBox(18, 26, rot, 0, 16); 
		graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF,0x34929A,0x2B5580], [1,1,1], [0,50,255], gbm); 
		graphics.drawRoundRect(0,10, 18,26,4);
		graphics.endFill();
		filters = [ new DropShadowFilter(4, 45, 0xFF7268, 1, 10, 10,1, 3, false, false, false ) ] ;	
	}
}
class back_ground extends Sprite{
public function back_ground(){
	var arr:Array=[0xFFD7AB,0xFFCCA7,0xFFC2A5,0xFFB8A2,0xFFAEA0,0xC6D0B8,0xD4C8B2,0xF2B4A5,0xFFB67F,0xE2BDAB,0xFED78A,0xFEE1B7,0xFCC4AD,0xFBA09B,0xFEAA9F
				   		,0xFFD7AB,0xFFCCA7,0xFFC2A5];
	for(var j:uint=0; j < 100; j++) {
		var panel:Sprite=new Sprite();
		var rc:uint=arr[Math.floor (Math.random() * arr.length)];
		var xx:Number=j % 10*46;
		var yy:Number=Math.floor(j / 10)*46;
		panel.graphics.beginFill(rc,1);
		panel.graphics.drawRect(xx,yy,46,46);
		graphics.endFill();
		addChild(panel);
	}
}
}