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

forked from: forked from: forked from: forked from: flash on 2010-3-9

wonderful本の写経
Get Adobe Flash player
by hacker_hd7shtvc 17 Mar 2010
    Embed
/**
 * Copyright hacker_hd7shtvc ( http://wonderfl.net/user/hacker_hd7shtvc )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pLTn
 */

// forked from hacker_hd7shtvc's forked from: forked from: forked from: flash on 2010-3-9
// forked from hacker_hd7shtvc's forked from: forked from: flash on 2010-3-9
// forked from hacker_hd7shtvc's forked from: flash on 2010-3-9
// forked from hacker_hd7shtvc's flash on 2010-3-9
//wonderful本の写経

package {
	import flash.geom.Matrix;
	import flash.events.Event;
	import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.geom.ColorTransform;
    import flash.display.BlendMode;
    import flash.geom.ColorTransform;   
    [SWF(width=465,height=465,backgroundColor=0,frameRate=30)]

    public class BitmapDataSample extends Sprite {
    	
    	
    	private var bmpdata:BitmapData;
    	private var sprite:Sprite;
    	private var matrix:Matrix;
    	private var colortrans:ColorTransform;
    	private var bmpcolortrans:ColorTransform;
    	
        public function BitmapDataSample() {
            // BtmapData作成
            
            bmpdata = new BitmapData( 465, 465, false, 0 );
            addChild( new Bitmap(bmpdata) );
            
            //グラッフィック作成
            sprite = newFig( 0, 0, 40, 0xFFFFFF );
            //Matrixの初期化
            matrix = new Matrix();
            
            colortrans = new ColorTransform();
            
            // エフェクトの初期か
            bmpcolortrans = new ColorTransform( 0.99, 0.99, 0.99 );
            
            //イベント
            addEventListener( Event.ENTER_FRAME,enterframe );
            stage.addEventListener( MouseEvent.CLICK,reset );
        }
            
        
        
      private function enterframe( e:Event):void {
      	//エフェクトの適応
      	bmpdata.colorTransform( bmpdata.rect, bmpcolortrans );
      	
      	
      	//変形
      	matrix.identity();
      	var s:Number = Math.random()*2;
      	matrix.scale( s,s );
      	matrix.rotate(Math.PI*Math.random());
      	matrix.translate(mouseX,mouseY);
      	
      	//色変換
      	colortrans.greenMultiplier = mouseX / 465;
      	colortrans.blueMultiplier = mouseY / 465;
      	colortrans.alphaMultiplier = Math.random();
      	
      	//Bitmapdataへ
     
      	
      	bmpdata.draw(sprite,matrix,colortrans,BlendMode.ADD );
      }
     
private function reset(e:MouseEvent):void {
	bmpdata.fillRect( bmpdata.rect,0xFF00000 );
}

        private function newFig( cx:Number, cy:Number, size:Number, col:uint ):Sprite {
            //中心(cx,cy), 幅高さsize, 色col のグラフィックを生成
            var shape:Sprite = new Sprite();
            shape.graphics.lineStyle( 0, 0x000000, 0.3 );
            shape.graphics.beginFill( col );
            shape.graphics.drawCircle( cx, cy, size*0.5 );
            shape.graphics.drawCircle( cx, cy, size*0.4 );
            var w:Number = size * 0.6;
            var h:Number = size * 0.15;
            shape.graphics.drawRect( cx - w/2, cy - h/2, w, h );
            shape.graphics.endFill();
            return shape;
        }
      
    }
}