/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xJHM
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
vecRect = new Vector.<xRect>(0, false);
var a:xRect;
var i:int;
for (i = 0; i < 16; i++)
{
a = new xRect();
a.cx = 64 + i *16;
a.cy = 200;
a.my = a.cy;
vecRect.push(a);
}//nexti
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var vecRect:Vector.<xRect>;
public var wang:Number = 0;
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(2,0);
var mx:Number;
var my:Number;
var i:int;
var num:int;
var a:xRect;
var b:xRect;
mx = stage.mouseX;
my = stage.mouseY;
num = vecRect.length;
graphics.drawRect(32,200-40,16,40);
graphics.drawRect(32+300-16,200-40,16,40);
graphics.drawRect(mx-8, 200-30,16,30);
graphics.drawRect(0,200, 48, 200);
graphics.drawRect(32+300-16,200,200,200);
wang += 0.04;
graphics.beginFill(0xFF, 0.5);
graphics.drawRect(0,300+(Math.cos(wang)*Math.sin(wang))*8,500,200);
graphics.endFill();
for (i = 0; i < num; i++)
{
a = vecRect[i];
graphics.drawCircle(a.cx, a.cy, 5);
a.cy = a.my;
//if (a.cy > my)
{
if (a.cx - 8 < mx)
if (a.cx + 8 > mx)
{
a.cy = a.my + 8;
if (i > 0) { b = vecRect[i-1]; b.cy = a.my+4; }
if (i < num-1) { b = vecRect[i+1]; b.cy = a.my+4;}
}
}//endif
}//nexti
}//onenter
}//classend
}
internal class xRect
{
public var cx:Number = 0;
public var cy:Number = 0;
public var my:Number = 0;
}