forked from: forked from: 絶対に押さないで - Don't push me
LIVE CODING 2010/04/21 18:10~19:25
押すなよ、絶対におすなよ。
イラッとした人ごめんなさい。
/**
* Copyright makc3d ( http://wonderfl.net/user/makc3d )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1130
*/
// forked from clockmaker's forked from: 絶対に押さないで - Don't push me
// forked from shohei909's 絶対に押さないで - Don't push me
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.*;
import flash.net.*;
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 );
addEventListener( MouseEvent.CLICK, onCLick );
}
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 );
}
}
public function onCLick(e:MouseEvent):void {
removeEventListener ( MouseEvent.CLICK, onCLick );
var l:Loader = new Loader; l.x = -50;
l.load (new URLRequest ("http://loopzy.com/files/Longcat.City.1.swf"));
addChild (l);
}
}
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;
}
}