/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/whmR
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
myFrame = new xFrame(3);
myFrame.vecRect[0].setValue(20, 10, 8, 32);
myFrame.vecRect[1].setValue(-20,10,8,32);
myFrame.vecRect[2].setValue(0, -10, 16,16);
vecFrame = new Vector.<xFrame>(0, false);
var a:xFrame;
a = new xFrame(3);
a.vecRect[0].setValue(20, 10, 8, 32);
a.vecRect[1].setValue(-20,-10,8,32);
a.vecRect[2].setValue(0, -10, 16,16);
vecFrame.push(a);
//1
a = new xFrame(3);
a.vecRect[0].setValue(20, 10, 8, 32);
a.vecRect[1].setValue(-20,10,8,32);
a.vecRect[2].setValue(0, -10, 16,16);
vecFrame.push(a);
//2
a = new xFrame(3);
a.vecRect[0].setValue(30, -10, 8, 32);
a.vecRect[1].setValue(-20,10,8,32);
a.vecRect[2].setValue(0, -10, 16,16);
vecFrame.push(a);
//3
a = new xFrame(3);
a.vecRect[0].setValue(30, 10, 8, 32);
a.vecRect[1].setValue(-20,10,8,32);
a.vecRect[2].setValue(10, -10, 16,16);
vecFrame.push(a);
//4
a = new xFrame(3);
a.vecRect[0].setValue(20, 10, 8, 32);
a.vecRect[1].setValue(-20,-10,8,32);
a.vecRect[2].setValue(0, -10, 16,16);
vecFrame.push(a);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var myFrame:xFrame;
public var vecFrame:Vector.<xFrame>;
public var ak:int = 1;
public var wait:int = 10;
public var ax:Number = 200;
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(2, 0);
//myFrame.render(graphics, 200, 200);
wait -= 1;
if (wait <= 0)
{ wait = 10; ak +=1;
// if (ak == 3) { ax += 0;}
if (ak == 4) { ax += 10;}
if (ax >= 400) { ax = 100;}
if (ak >= vecFrame.length) { ak = 1;}
}
var f:xFrame;
f = vecFrame[ak];
f.render(graphics, ax, 200);
graphics.moveTo(0, 240+4);
graphics.lineTo(400, 240+4);
graphics.drawCircle(ax, 250, 4);
}//onenter
}//classend
}
import flash.display.Graphics;
internal class xFrame
{
public var numRect:int = 0;
public var vecRect:Vector.<xRect>;
public function xFrame(num:int)
{
numRect = num;
var i:int;
vecRect = new Vector.<xRect>(numRect, false);
for (i = 0; i < numRect;i++){ vecRect[i]=new xRect();}
}//ctor
public function render(g:Graphics, ax:Number, ay:Number):void
{
var i:int;
var num:int;
var a:xRect;
num=vecRect.length;
for (i = 0; i < num;i++)
{
a= vecRect[i];
g.drawRect(a.cx-a.xrad+ax,a.cy-a.yrad+ay,a.xrad+a.xrad,a.yrad+a.yrad);
}
}//render
}//xframe
internal class xRect
{
public var cx:Number = 0;
public var cy:Number = 0;
public var xrad:Number = 8;
public var yrad:Number = 8;
public function setValue(x:Number, y:Number, xr:Number, yr:Number):void
{
cx = x; cy = y; xrad = xr; yrad = yr;
}
}//classend