flash on 2013-10-29
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/stxY
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(2,0);
var ax:Number;
var ay:Number;
var aw:Number;
var ah:Number;
var ax2:Number;
var ay2:Number;
var bx:Number;
var by:Number;
var bw:Number;
var bh:Number;
var bx2:Number;
var by2:Number;
ax = 60;
ay = 60;
aw = 200;
ah = 200;
bx = stage.mouseX-60;
by = stage.mouseY-60;
bw = 120;
bh = 90;
graphics.beginFill(0,0.1);
graphics.drawRect(ax,ay,aw,ah);
graphics.endFill();
graphics.beginFill(0,0.1);
graphics.drawRect(bx,by,bw,bh);
graphics.endFill();
ax2 = ax+aw;
ay2 = ay+ah;
bx2 = bx+bw;
by2 = by+bh;
var kx:Number;
var ky:Number;
var kx2:Number;
var ky2:Number;
kx = Math.min(ax,bx);
ky = Math.min(ay,by);
kx2 = Math.max(ax2,bx2);
ky2 = Math.max(ay2,by2);
graphics.lineStyle(3,0xFF0000,0.5);
graphics.drawRect(kx,ky,kx2-kx,ky2-ky);
kx2 = Math.min(ax2,bx2);
ky2 = Math.min(ay2,by2);
kx = Math.max(ax,bx);
ky = Math.max(ay,by);
graphics.lineStyle(4,0x00FF00,0.5);
graphics.beginFill(0x00FF00,0.2);
graphics.drawRect(kx,ky,kx2-kx,ky2-ky);
graphics.endFill();
}//onenter
}//classend
}