flash on 2014-12-27
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8BQR
*/
package {
import flash.text.TextField;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
deb = new TextField();
deb.width =320;
deb.height=240;
deb.mouseEnabled=false;
addChild(deb);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var deb:TextField;
public var cx:Number = 230;
public var cy:Number = 230;
public var vx:Number = 0;
public var vy:Number = 0;
public var wx:Number = 0;
public var gt:int = 0;
public var pm:Number =0;
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(2, 0);
var mx:Number; var my:Number;
mx = stage.mouseX;
my = stage.mouseY;
wx += 1;
var ax:Number;
var ay:Number;
ax = 230;
ay = 230;
if (wx < 90)
{
var ang:Number; var wa:Number;
var m:Number; var d:Number;
var m2:Number; //var pm:Number;
d = 32;
wa = wx *0.4;
m = 32;
m = Math.sin(wa)*d;
m2 = Math.cos(wa)*d;
ang = Math.atan2(ay-my, ax-mx);
var kx:Number; var ky:Number;
kx = Math.cos(ang)*m+ax;
ky = Math.sin(ang)*m+ay;
graphics.moveTo(ax,ay);
graphics.lineTo(kx, ky);
kx += Math.cos(ang+1.57)*m2;
ky += Math.sin(ang+1.57)*m2;
graphics.moveTo(ax,ay);
graphics.lineTo(kx, ky);
//cx = kx; cy= ky;
cx += (kx-cx)*0.5;
cy += (ky-cy)*0.5;
deb.text = " "+m+"\n" + pm + "\n"+wx;
if (wx > 60)
{
if ( m < pm && m <= (d*-0.5))
{
ang = Math.atan2(my-cy, mx-cx);
vx += Math.cos(ang)*16;
vy += Math.sin(ang)*16;
wx = 92;
}
}
pm =m;
/*
ang = Math.atan2(ay-cy, ax-cx);
graphics.moveTo(cx,cy);
graphics.lineTo(Math.cos(ang)*16+cx, Math.sin(ang)*16+cy);
vx += Math.cos(ang)*0.3;
vy += Math.sin(ang)*0.3;
ang += 1.57;
vx += Math.cos(ang)*0.3;
vy += Math.sin(ang)*0.3;
vx *= 0.95; vy*=0.95;
*/
// vx += Math.cos(wx*0.1)*0.4;
// vy += Math.sin(wx*0.1)*0.4;
}
/*
else if (wx < 162)
{
ang = Math.atan2(my-cy, mx-cx);
vx += Math.cos(ang)*8;
vy += Math.sin(ang)*8;
}
*/
if (wx >= 140) { wx = 0; }
vx *= 0.98; vy *= 0.98;
cx += vx; cy += vy;
if (cx < 0) { cx= 460;} if (cx > 460) {cx = 0; }
if (cy < 0) { cy=460;} if (cy > 460) { cy = 0;}
graphics.drawCircle(ax, ay, 4);
graphics.drawCircle(cx,cy, 16);
graphics.drawCircle(mx,my, 8);
}//onenter
public function getMag(ax:Number, ay:Number):Number
{ return Math.sqrt(ax*ax+ay*ay); }
}//classend
}