flash on 2016-10-16
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/y8xE
*/
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.mouseEnabled = false;
deb.width=320;
deb.height=240;
addChild(deb);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var deb:TextField;
public var x0:Number = 130;
public var y0:Number = 110;
public var x1:Number = 130;
public var y1:Number = 150;
public var x2:Number = 180;
public var y2:Number = 130;
public var u0:Number = 0;
public var nt:int = 0;
public var ang:Number = 0;
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(2, 0);
camy = 150;
camx=-150;
drawBox2(0,0,0, 256,-16,256)
var cx:Number; var cy:Number;
var ax:Number; var ay:Number;
ax = x0+(x1-x0)*u0;
ay = y0+(y1-y0)*u0;
cx = (ax+x2)*0.5;
cy = (ay+y2)*0.5;
var tu:Number;
tu = Math.sin(u0*3.1415) * 32; //16;
deb.text = " "+tu+"\n"+u0;
drawBox3(x2, 0+4 , y2, 8,8,8);
drawBox3(ax, tu+4, ay, 8,8,8);
drawBox3(cx, 32+tu*0.5, cy, 16,16,16);
drawBox3(x2, 0 , y2, 8,1,8);
drawBox3(ax, 0, ay, 8,1,8);
drawBox3(cx, 0, cy, 16,1,16);
var ta:Number; ta = ang;
ta+=1.57;
drawBox3(cx+Math.cos(ta)*16, 0, cy+Math.sin(ta)*16, 4,1,4);
// ang +=0.01;
u0+=0.05;
if (u0>=1.0)
{
// u0=1.0;
x0 = x2;
y0 = y2;
x2 = x1;
y2 = y1;
x1 = x0 + Math.random()*32-16;
y1 = y2 + 32;
x1 =cx+Math.cos(ta)*64;
y1 =cy+Math.sin(ta)*64;
x1 += Math.sin(ta) * (nt==0? 16 : -16);
y1 += Math.cos(ta) * (nt==0? -16 : 16);
nt = nt == 1 ? 0 : 1;
ang += 0.35;
u0 =0.0;
if (cy>365)
{ y0-=465;y1-=465;y2-=465; }
if (cx > 365)
{ x0-=465; x1-=465; x2-=465; }
}//endif
}//onenter
public var camx:Number = 0; public var camy:Number = 0; public var camz:Number = 0;
public var rendw:Number = 465 * 0.5; public var rendh:Number = 465 * 0.5;
public function drawLine(ax:Number, ay:Number, az:Number,
bx:Number, by:Number, bz:Number):void
{
var sx:Number; var sy:Number;
ax -= camx; ay -= camy; az -= camz;
bx -= camx; by -= camy; bz -= camz;
sx = ax - az + rendw; sy = (ax * 0.5) + (az * 0.5) - ay;
graphics.moveTo(sx, sy);
sx = bx - bz + rendw; sy = (bx * 0.5) + (bz * 0.5) - by;
graphics.lineTo(sx, sy);
}//drawline
public function drawBox3(ax:Number,ay:Number,az:Number,
rx:Number,ry:Number,rz:Number):void
{ drawBox(ax-rx,ay-ry,az-rz,ax+rx,ay+ry,az+rz); }
public function drawBox2(ax:Number,ay:Number,az:Number,
aw:Number,ah:Number,ad:Number):void
{ drawBox(ax,ay,az, ax+aw,ay+ah,az+ad); }
public function drawBox(ax:Number, ay:Number, az:Number,
bx:Number, by:Number, bz:Number):void
{
drawLine(ax, ay, az, bx, ay, az);
drawLine(ax, by, az, bx, by, az);
drawLine(ax, ay, bz, bx, ay, bz);
drawLine(ax, by, bz, bx, by, bz);
drawLine(ax, ay, az, ax, by, az);
drawLine(bx, ay, az, bx, by, az);
drawLine(ax, ay, bz, ax, by, bz);
drawLine(bx, ay, bz, bx, by, bz);
drawLine(ax, ay, az, ax, ay, bz);
drawLine(bx, ay, az, bx, ay, bz);
drawLine(ax, by, az, ax, by, bz);
drawLine(bx, by, az, bx, by, bz);
}//drawbox
}//classend
}