array nav 2
forked from text and timer (diff: 128)
shitty ball shit
ActionScript3 source code
/**
* Copyright Highly ( http://wonderfl.net/user/Highly )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eVwv
*/
// forked from Highly's text and timer
package {
import flash.events.KeyboardEvent;
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.Event;
import flash.geom.Point;
public class FlashTest extends Sprite {
public function FlashTest() {
var ti:Timer = new Timer(100,0);
ti.addEventListener(TimerEvent.TIMER,tmr);
ti.start();
var gc:int=30;
var sn:Number = 0.91;
var i:int=0;
var n:int=0;
var q:int=0;
var a:Array = [];
var out1:TextField = new TextField();
out1.x=0;
out1.y=0;
out1.selectable = false;
out1.multiline = true;
out1.wordWrap = true;
out1.width = stage.stageWidth;
out1.height = stage.stageHeight;
out1.text = "";
addChild(out1);
while(i<gc){
n=0;
a.push([]);
while(n<gc){
a[i].push(0);
++n;
}
++i;
}
var pt:Point = new Point(0,0);
function tmr(e:TimerEvent):void{
nav();
calc();
prnt();
}
function nav():void{
if(ku){
pt.y--;
}
if(kd){
pt.y++;
}
if(kr){
pt.x++;
}
if(kl){
pt.x--;
}
}
function calc():void{
if(pt.x>gc-1){
pt.x=gc-1;
}
if(pt.x<0){
pt.x = 0;
}
if(pt.y>gc-1){
pt.y=gc-1;
}
if(pt.y<0){
pt.y=0;
}
i=0;
while(i<a.length){
n=0;
while(n<a[i].length){
if(a[i][n]!=a[pt.y][pt.x]){
a[i][n]*=sn;
}
++n;
}
out1.appendText("\n");
++i;
}
a[pt.y][pt.x] = 9;
}
function prnt():void{
out1.text="";
i=0;
while(i<a.length){
n=0;
while(n<a[i].length){
out1.appendText(Math.round(a[i][n])+" ");
++n;
}
out1.appendText("\n");
++i;
}
}
var ku:Boolean = false, kd:Boolean = false, kr:Boolean = false, kl:Boolean = false;
function kpd(e:KeyboardEvent):void{
//up = 38 down = 40 right = 39 left = 37
if(e.keyCode == 38){
ku = true;
}
if(e.keyCode == 40){
kd = true;
}
if(e.keyCode == 39){
kr = true;
}
if(e.keyCode == 37){
kl = true;
}
}
function kpu(e:KeyboardEvent):void{
if(e.keyCode == 38){
ku = false;
}
if(e.keyCode == 40){
kd = false;
}
if(e.keyCode == 39){
kr = false;
}
if(e.keyCode == 37){
kl = false;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP, kpu);
stage.addEventListener(KeyboardEvent.KEY_DOWN, kpd);
}
}
}
