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: 残像

残像エフェクト。
@author siba
Get Adobe Flash player
by nopants 06 May 2009
// forked from siba2260's 残像
// forked from siba2260's code on 2008-12-18
// write as3 code here..
package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.PixelSnapping;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	
	[SWF(width=800, height=600, backgroundColor=0xAADD00)]

	/**
	 * 残像エフェクト。
	 * @author siba
	 */
	public class Main17 extends Sprite {
		
		// ----------------------------
		//	メンバ変数
		// ----------------------------
		
		private var afterBitmapData:BitmapData = new BitmapData(800, 600, false, 0x000000);
		private var afterImage:Bitmap = new Bitmap(afterBitmapData, PixelSnapping.AUTO, true);
		private var character:Character = new Character();
		
		
		// ----------------------------
		//	初期化
		// ----------------------------
		
		public function Main17() {
			addChild(afterImage);
			
			character.x = 200;
			character.y = 200;
			addChild(character);
			
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		
		// ----------------------------
		//	イベント
		// ----------------------------
		
		private function onEnterFrame(event:Event):void {
			
                        afterBitmapData.colorTransform(afterBitmapData.rect, 
						new ColorTransform(1, 1, 1, 1, 0, 5, 0, -3));

                        var mat1:Matrix = new Matrix();
                        mat1.scale(0.04*character.x, 0.04*character.y);
                        mat1.translate(character.x, character.y);
                                              
                        var mat2:Matrix = new Matrix();
                        mat2.scale(0.04*character.y, 0.04*character.x);
                        mat2.translate(stage.stageWidth-character.x, stage.stageHeight-character.y);

                        var mat3:Matrix = new Matrix();
                        mat3.scale(.04*character.x, .04*character.y);
                        mat3.translate(stage.stageWidth-character.x, character.y);
                        
                        var mat4:Matrix = new Matrix();
                        mat4.scale(.04*character.x, .04*character.y);
                        mat4.translate(character.x, stage.stageHeight-character.y);
                        
			afterBitmapData.draw(character, mat1);
                        afterBitmapData.draw(character, mat2);
                        afterBitmapData.draw(character, mat3);
                        afterBitmapData.draw(character, mat4);
                        
		}
		
	}
}


// ------------------------------------
//	内部クラス
// ------------------------------------

import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.GradientType;

class Character extends Sprite {
	
	// --------------------------------
	//	メンバ変数
	// --------------------------------
	
	private var isStage:Boolean = false;
	
	
	// --------------------------------
	//	初期化
	// --------------------------------
	
	public function Character() {
    
                var fillType:String = GradientType.LINEAR;
                var colors:Array = [0x00FF00,0xFF0000];
                var alphas:Array = [100,100];
                var ratios:Array = [0,255];
                
                graphics.beginGradientFill(fillType,colors,alphas,ratios);
                graphics.drawCircle(0,0,4);
                graphics.endFill();
                

		addEventListener(Event.ADDED_TO_STAGE, onAddedStage);
               
	}
	
	
	// --------------------------------
	//	パブリック
	// --------------------------------
	
	public function mouseMove(e:MouseEvent):void {
               x = stage.mouseX;
               y = stage.mouseY;
        }
	
	// --------------------------------
	//	イベント
	// --------------------------------
	
	private function onAddedStage(event:Event):void {
		isStage = true;
                stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
	}
	
}