flash on 2016-3-13
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/O3Oe
*/
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 ang:Number = 0;
public function onEnter(e:Event):void
{
var mx:Number; var my:Number;
graphics.clear();
graphics.lineStyle(2, 0);
mx = stage.mouseX; my = stage.mouseY;
ang +=0.01;
var xr:Number; var yr:Number;
var ax:Number; var ay:Number;
ax = 230; ay = 230;
xr = 64; yr =32;
var nx:Number; var ny:Number;
var ux:Number; var uy:Number;
nx = Math.cos(ang);
ny = Math.sin(ang);
ux = -ny;
uy = nx;
graphics.drawCircle(ax,ay,4);
graphics.moveTo(ax+nx*xr +ux*yr, ay+ny*xr +uy*yr);
graphics.lineTo(ax+nx*-xr+ux*yr, ay+ny*-xr +uy*yr);
graphics.lineTo(ax+nx*-xr+ux*-yr, ay+ny*-xr +uy*-yr);
graphics.lineTo(ax+nx*xr +ux*-yr, ay+ny*xr +uy*-yr);
graphics.lineTo(ax+nx*xr +ux*yr, ay+ny*xr +uy*yr);
var rx:Number; var ry:Number;
mx -=ax; my-=ay;
rx = mx * Math.cos(-ang) - my * Math.sin(-ang);
ry = mx * Math.sin(-ang) + my * Math.cos(-ang);
mx+=ax;my+=ay;
// graphics.drawCircle(rx+ax,ry+ay, 8);
var ix:Number; var iy:Number;
if (rx < -xr) { ix = -xr; }
else if (rx > xr) { ix = xr;}
else { ix = rx; }
if (ry < -yr) { iy = -yr; }
else if (ry > yr) { iy = yr;}
else { iy = ry; }
rx = ix * Math.cos(ang) - iy * Math.sin(ang);
ry = ix * Math.sin(ang) + iy * Math.cos(ang);
ix = rx+ax; iy = ry+ay;
graphics.drawCircle(ix,iy,5);
graphics.moveTo(ix,iy);
graphics.lineTo(mx,my);
}//onenter
}//classend
}