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 2009-5-24

import As.*;
import flash.filters.DropShadowFilter; 
import flash.display.MovieClip;
import flash.utils.*;
Get Adobe Flash player
by muu 16 Jan 2010
/**
 * Copyright muu ( http://wonderfl.net/user/muu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/obZ0
 */

package{   
  import flash.display.Sprite;                
  import flash.text.TextField; 
  //import As.*;
  //import flash.filters.DropShadowFilter; 
  import flash.events.Event;
  import flash.events.MouseEvent;
  import flash.display.*;
  //import flash.display.MovieClip;
  import flash.utils.setInterval;
  import flash.utils.Timer;
  import flash.events.TimerEvent;
  //import flash.utils.*;
  import flash.geom.Point; 
  
  public class Main extends Sprite {   
    public function Main() { 

    var mm:Array = new Array();
    
    for(var i:int = 0 ; i < 5 ; i++){ 
        var mc:Sprite = new Sprite();
        mm[i] = mc;
        addChild(mm[i]);
        mm[i].x = i*100
        mm[i].y = 100;
        mm[i].graphics.beginFill(0xaaaaaa);
        mm[i].graphics.drawRect(0, 0, 50, 50);
        mm[i].graphics.endFill();
    	mm[i].addEventListener(MouseEvent.MOUSE_OVER,m_over);
	mm[i].addEventListener(MouseEvent.MOUSE_OUT,m_out);
    }

    function m_over(event:Event):void{
        moveMC2(event.target , Math.random()*-400+400 , Math.random()*-400+400);
    }
    function m_out(event:Event):void{
    }    
    
    //移動関数 揺れながら移動
    function moveMC2( mc:Sprite , targetX:int , targetY:int):void{
	var rot:int = 0;//速度
	var xx:Number = mc.x;    // 初期位置X 
	var yy:Number = mc.y;    // 初期位置Y
	var tx:Number = targetX; // 目標位置X
	var ty:Number = targetY; // 目標位置Y
	var yureX:Number = 0;    // 揺れ幅X
	var yureY:Number = 0;    // 揺れ幅Y
	var yure:Number = 30;    //  弾みぐあい
        var dx:int;              //
        var dy:int;              //
	
	mc.addEventListener(Event.ENTER_FRAME,function():void{
		rot += yure;  // 揺れの速度を設定
		yureX = (tx - xx) ;
		yureY = (ty - yy) ;
		dx = (targetX - Math.cos( rot * Math.PI / 180) * yureX); //x軸移動座標取得
		dy = (targetY - Math.cos( rot * Math.PI / 180) * yureY); //y軸移動座標取得
		if(tx > 0.5 ){  //揺れ幅の減算
			tx -= tx/5;
			ty -= ty/5;
		}else{
			tx = ty = 0;
		}
		if (xx > 0.5 ){ //目標座標までの差を減算
			xx -= xx/5;	
			yy -= yy/5;
		}else{
			xx = yy = 0;
		}
		if ( (tx + xx) == 0){
			mc.removeEventListener(Event.ENTER_FRAME,arguments.callee);
		}
		mc.x = dx;
		mc.y = dy;
	});
    }

            
    }
  }
}