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

絶対に押さないで - Don't push me

LIVE CODING 2010/04/21 18:10~19:25
押すなよ、絶対におすなよ。
イラッとした人ごめんなさい。
Get Adobe Flash player
by shohei909 21 Apr 2010
/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jShL
 */

package {
	//LIVE CODING 2010/04/21 18:10~19:25
	
	//押すなよ、絶対におすなよ。
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	//イラッとした人ごめんなさい。
	
	
	
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            addChild( new Dammy() );
        }
    }
}

import flash.display.*;
import flash.text.*;
import flash.events.*;

class Dammy extends Sprite{
	public var position:Dot = new Dot(232,232);
	public var text:TextField = new TextField();
	public var button:Sprite = new Sprite();
	
	
	public function Dammy(){
		var format:TextFormat = new TextFormat();
		with(format){
			align = "center"
		}
		with(text){
			selectable = false;
			
			autoSize = TextFieldAutoSize.CENTER;
			wordWrap = false;
			defaultTextFormat = format;
			
			text = "Don't push me!!";
		}
		
		
		button.addChild(text);
		addChild(button);
		
		
		button.x = position.x -  text.width / 2;
		button.y = position.y -  text.height / 2;
		with(button.graphics){
			lineStyle( 1, 0x666666, 1.0 );
			beginFill( 0xF0F0F0, 1 );
			drawRoundRect( 0, 0, 100, 21, 8 );
		}
		
		
		addEventListener( Event.ENTER_FRAME, onFrame );
		addEventListener( MouseEvent.MOUSE_OVER, onOver );
		addEventListener( MouseEvent.MOUSE_OUT, onOut );
	}
	
	public function onFrame(e:Event):void{
		position.escape(mouseX , mouseY , 100);
		
		button.x = position.x -  text.width / 2;
		button.y = position.y -  text.width / 2;
	}
	public function onOver(e:Event):void{
		with(button.graphics){
			clear();
			lineStyle( 1, 0x666666, 1.0 );
			beginFill( 0xE0E0E0, 1 );
			drawRoundRect( 0, 0, 100, 21, 8 );
		}
	}
	
	public function onOut(e:Event):void{
		with(button.graphics){
			clear();
			lineStyle( 1, 0x666666, 1.0 );
			beginFill( 0xF0F0F0, 01 );
			drawRoundRect( 0, 0, 100, 21, 8 );
		}
	}
	
}
class Dot{
	public var x:int;
	public var y:int;
	public var px:int;
	public var py:int;
	
	
	public function Dot( _x:int, _y:int ){
		x = _x; y = _y;
		px = x; py = y;
	}
	public function escape( mx:int , my:int , r:int ):void{
		var targetX:int;var targetY:int;
		if( (px-mx)*(px-mx) + (py-my)*(py-my) <= r*r ){
			var d:Number = Math.atan2( px-mx, py-my );
			
			targetX = px + Math.sin(d)*r;
			targetY = py +  Math.cos(d)*r;
			
		}else{
			targetX = px; targetY = py;	
		}
		
		x = (targetX+x)/2;
		y = (targetY+y)/2;
		
		
	}
	
}