flash on 2014-11-24
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fuue
*/
package {
import flash.text.TextField;
import flash.display.GradientType;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.display.BitmapData;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
deb = new TextField();
deb.x = 8; deb.y = 465-128+8;
deb.width = 320; deb.height= 96;
deb.mouseEnabled = false;
deb.textColor=0xFFffFF;
deb.thickness=2;
addChild(deb);
img = new BitmapData(32,32,false,0);
img.perlinNoise(23,23,5,21,true,true,2);
img.colorTransform(img.rect, new ColorTransform(0.5,0.5,0.5));
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var deb:TextField;
public var img:BitmapData;
public var cx:Number = 230;
public var cy:Number = 230;
public var px:Number = 100;
public var py:Number = 80;
public var gt:int = 0;
public var state:int = 0;
public var mt:Number = 0;
public var cur:int = 0;
public var msg:String = "1232183972489487583843294834892374832479248728941923";
public function getDist(ax:Number,ay:Number):Number
{ return Math.sqrt(ax*ax+ay*ay); }
public function onEnter(e:Event):void
{
var mx:Number; var my:Number;
mx = stage.mouseX;
my = stage.mouseY;
graphics.clear();
graphics.lineStyle(2, 0);
graphics.beginBitmapFill(img,null,true,false);
graphics.drawRect(0,0,465,465);
graphics.endFill();
cx += (mx-cx)*0.1;
cy += (my-cy)*0.1;
graphics.beginFill(0xFFffFF);
graphics.drawCircle(cx,cy,8);
graphics.endFill();
//npc
graphics.beginFill(0xFFffFF);
graphics.drawCircle(px,py,12);
graphics.endFill();
if (getDist(px-cx,py-cy) < 60) { state =1;}
else { state = 0; }
if (state == 1)
{ mt +=0.1; if (mt > 1) {mt=1; } cur+=2; }
else { mt -=0.1; if (mt < 0) {mt=0; cur =0;}}
deb.alpha = mt;
//deb.text = "TESTING TESTING";
if (state == 1) { deb.text = msg.substr(0, cur) + ((gt & 16) > 0 ? "_":""); }
//avatar thing
graphics.lineStyle(4,0);
graphics.beginFill(0xFFffFF);
graphics.drawCircle(465+100-140*mt,465-128-32,96);
graphics.endFill();
//backdrop
graphics.lineStyle();
//graphics.beginGradientFill(GradientType.LINEAR,[0xFF,0],[1,1],[0.1,0.5]);
graphics.beginFill(0xFF,0.5*mt);
graphics.drawRect(0,465-128,465,128);
graphics.endFill();
//pointer
graphics.lineStyle(2,0xFFffFF);
graphics.moveTo(mx-8,my); graphics.lineTo(mx+8,my);
graphics.moveTo(mx,my-8); graphics.lineTo(mx,my+8);
gt += 1;
}//onenter
}//classend
}