[FF]: Tiles
forked from Tiles (diff: 64)
ActionScript3 source code
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8JSd
*/
// forked from mach51's Tiles
package
{
import flash.display.MovieClip;
[SWF(width = '500', height = '500', backgroundColor = '0xffffff', frameRate = '100')]
public class Tiles extends MovieClip
{
public var map:Array =
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
public const COLUMNS:int = 20;
public const SIDE:Number = Tile.getSideLength(stage.stageWidth, COLUMNS);
public var blueTile:Tile = new Tile(0, 0xE8E8E8, SIDE);
public var redTile:Tile = new Tile(1, 0xff0011, SIDE);
public function Tiles()
{
map.forEach(drawTiles);
}
public function drawTiles(id:int, i:int, ar:Array):void
{
switch(id)
{
case 0:
var k:Tile = new Tile(blueTile.getID(), blueTile.getColour(), SIDE);
addChild(k);
k.x = ( i % COLUMNS * SIDE)*.55;
k.y = ( Math.floor(i / COLUMNS) * SIDE)*.55;
break;
case 1:
var b:Tile = new Tile(redTile.getID(), redTile.getColour(), SIDE);
addChild(b);
b.x = ( i % COLUMNS * SIDE)*.55;
b.y = ( Math.floor(i / COLUMNS) * SIDE)*.55;
break;
}
}
} // class end
} // end package
import flash.display.MovieClip;
class Tile extends MovieClip
{
private var s:Number; // stageWidth/columns
private var id:int;
private var colour:uint;
public function Tile(id:int, colour:uint, s:Number)
{
this.id = id;
this.colour = colour;
this.s = s;
graphics.beginFill(this.colour);
graphics.drawCircle(s/2, s/2, s/6);
graphics.endFill();
}
public static function getSideLength(squareDimension:int, columns:int):Number
{
return squareDimension / columns;
}
public function getColour():uint
{
return this.colour;
}
public function getID():int
{
return this.id;
}
}