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

menu localToGlobal

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

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 = 100 + i*60
            mm[i].y = 200;
            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 , 1.5);
        }
        function m_out(event:Event):void{
            moveMC2(event.target , 1);
        } 
        
        //ズーム関数 揺れながらサイズ変更
        function moveMC2( mc:Sprite , scl:Number):void{
    	    var rot:int = 0;//速度
            var ts:Number = scl;         // 目標サイズ
	    var bs:Number = mc.scaleX;   // 初期サイズ 
	    var yureX:Number = 0;        // 揺れ幅X
	    var yure:Number = 20;        //  弾みぐあい
            var dx:Number;               //

            var bf_pos:Point = new Point(mc.x + mc.width/2, mc.y + mc.height/2);    //拡大前の中心点の記録
            mc.localToGlobal(bf_pos);      
        
	    addEventListener(Event.ENTER_FRAME,function():void{
 		rot += yure;  // 揺れの速度を設定
		yureX = (ts - bs);	
		dx = (scl - Math.cos( rot * Math.PI / 180) * yureX); 

                mc.scaleX = mc.scaleY = dx;
 
                var af_pos:Point = new Point(mc.x + mc.width/2, mc.y + mc.height/2);    //拡大後に中心点のずれを補正
                mc.localToGlobal(af_pos);
                mc.x += bf_pos.x - af_pos.x;
                mc.y += bf_pos.y - af_pos.y;

		if(ts > 0.05 ){  //揺れ幅の減算
			ts -= ts/10;
		}else{
			ts = 0;
		}
		if (bs > 0.05 ){ //目標サイズまでの差を減算
			bs -= bs/10;	
		}else{
			bs = 0;
		}
		if ((ts + bs) == 0){
			mc.removeEventListener(Event.ENTER_FRAME,arguments.callee);
		}
	    });
        }
    }
  }
}