flash on 2012-7-9
♥0 |
Line 53 |
Modified 2012-07-09 01:44:51 |
MIT License
archived:2017-03-20 15:17:38
ActionScript3 source code
/**
* Copyright jokehn9 ( http://wonderfl.net/user/jokehn9 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vpNi
*/
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Shape;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public var map:Array = [];
public function FlashTest() {
// write as3 code here..
//0 is dark :empty
//1 is led : z
//2 is yellow: reverese z 3 is green L 4 is 0xff8800 reverse L 5 is blue ㅁ, 6 is white I
const colors:Array = [0x0, 0xff0000, 0xffff00, 0xff00, 0xff8800, 0xff, 0xffffff];
const mapSx:Number = 16.25;
const mapSy:Number = 32.5;
const map_width:int = 200;
const map_height:int = 400;
const row_num:int = 10;
const col_num:int = 20;
var backGround:Shape = new Shape();
backGround.graphics.beginFill(0x0);
backGround.graphics.drawRect(0,0,465,465);
addChild(backGround);
for(var i:int = 0; i< 20;i++) {
map[i] = new rowData;
}
for(i=0;i<row_num;i++) {
for(var k:int = 0; k < col_num; k++) {
map[k].row[i] = 0;
}
}
var bd:BitmapData = new BitmapData(465,465,true,0x0);
updateMap(bd,mapSx,mapSy, map_width, map_height, 20);
addChild(new Bitmap(bd));
}
public function updateMap(bd:BitmapData, sx:Number, sy:Number, width:int =200, height:int = 400, size:int = 20):void {
var i:int = 0;
var k:int = 0;
var shape:Shape = new Shape();
for(i=0;i < height/size;i++) {
for(k=0; k < width/size;k++) {
if(map[i].row[k] == 0) {
shape.graphics.clear();
shape.graphics.lineStyle(1,0x777777);
shape.graphics.drawRect(0, 0, 20, 20);
shape.x = width / size * k*2 + sx ;
shape.y = height / size * i + sy ;
bd.draw(shape,shape.transform.matrix);
}
}
}
}
}
}
class rowData {
public var row:Array = [0,0,0,0,0,0,0,0,0,0];
}