flash on 2015-2-13
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mCTns
*/
package {
import flash.display.BitmapData;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
skin = new BitmapData(64,64, false, 0);
skin.perlinNoise(12,14,4,23, true,true);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var vecVert:Vector.<Number> = new Vector.<Number>(4*2, false);
public var vecUv:Vector.<Number> = new Vector.<Number>(4*3, false);
public var vecFace:Vector.<int> = Vector.<int>([0,1,2, 2,1,3]);
public var skin:BitmapData;
public var gt:int = 0;
public function onEnter(e:Event):void
{
graphics.clear();
//graphics.lineStyle(2, 0);
var ax:Number; var ay:Number;
var aw:Number; var ah:Number;
ax = 128; ay = 128;
aw = 128; ah = 128;
vecVert[0] = ax; vecVert[1] = ay;
vecVert[2] = ax+aw; vecVert[3] = ay;
vecVert[4] = ax-128; vecVert[5] = ay+ah;
vecVert[6] = ax+aw+128; vecVert[7] = ay+ah;
var u:Number;
u = gt *0.01;
vecUv[0] = u; vecUv[1] = 0; vecUv[2] = 1/3.14;
vecUv[3] = u+1; vecUv[4] = 0; vecUv[5] = 1/3.14;
vecUv[6] = u; vecUv[7] = 1; vecUv[8] = 1;
vecUv[9] = u+1; vecUv[10] = 1; vecUv[11] = 1;
graphics.beginBitmapFill(skin);
//graphics.beginFill(0xFF, 1);
graphics.drawTriangles(vecVert,vecFace,vecUv);
graphics.endFill();
gt += 1;
ax = 128; ay = 128+128+32;
aw = 128; ah = 128;
//aw = 256;
vecVert[0] = ax; vecVert[1] = ay;
vecVert[2] = ax+aw; vecVert[3] = ay;
vecVert[4] = ax; vecVert[5] = ay+ah;
vecVert[6] = ax+aw; vecVert[7] = ay+ah;
vecUv[0] = u; vecUv[1] = 0; vecUv[2] = 1/3.14;
vecUv[3] = u+1; vecUv[4] = 0; vecUv[5] = 1/3.14;
vecUv[6] = (u)+0.314; vecUv[7] = 1; vecUv[8] = 1;
vecUv[9] = (u+1)-0.314; vecUv[10] = 1; vecUv[11] = 1;
graphics.beginBitmapFill(skin);
//graphics.beginFill(0xFF, 1);
graphics.drawTriangles(vecVert,vecFace,vecUv);
graphics.endFill();
}//onenter
}//classend
}