flash on 2015-7-10
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/kbmV
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var gt:int =0;
public function onEnter(e:Event):void
{
gt+=1;
var mx:Number; var my:Number;
mx = stage.mouseX; my = stage.mouseY;
graphics.clear();
graphics.lineStyle(2, 0);
var ax:Number; var ay:Number;
var bx:Number; var by:Number;
var ta:Number;
ta = gt * 0.1;
ax= 230; ay= 230;
bx= mx + Math.cos(ta)*32; by =my + Math.sin(ta)*32;
graphics.drawCircle(mx,my, 32);
graphics.moveTo(mx+Math.cos(ta)*32, my+Math.sin(ta)*32);
graphics.lineTo(mx+Math.cos(ta)*-32, my+Math.sin(ta)*-32);
var mag:Number;
var nx:Number; var ny:Number;
nx=bx-ax;ny=by-ay;
mag = Math.sqrt(nx*nx+ny*ny);
if (mag == 0) { mag =0.1; }
nx/=mag; ny/=mag;
graphics.drawCircle(ax,ay, 8);
graphics.drawCircle(bx,by, 8);
//graphics.moveTo(ax,ay);
//graphics.lineTo(bx,by);
var kx:Number; var ky:Number;
kx = (bx+ax)*0.5 +ny*-16;
ky = (by+ay)*0.5 +nx* 16;
//graphics.drawCircle(kx,ky, 8);
var i:int;
var dx:Number; var dy:Number;
var r:Number;
r = 64;
for(i=0;i<8;i++)
{
if (i%2 == 0)
{ dx=kx-bx;dy=ky-by; }
else { dx=kx-ax;dy=ky-ay; }
mag = Math.sqrt(dx*dx+dy*dy);
if (mag == 0) { mag =0.1; }
dx/=mag; dy/=mag;
mag = r-mag; mag*=0.5;
kx += dx*mag; ky += dy*mag;
}//nexti
graphics.drawCircle(kx,ky, 8);
graphics.moveTo(ax,ay);
graphics.lineTo(kx,ky);
graphics.moveTo(kx,ky);
graphics.lineTo(bx,by);
}//onenter
}//classend
}