flash on 2010-11-26
♥0 |
Line 44 |
Modified 2010-11-26 15:41:47 |
MIT License
archived:2017-03-10 11:14:36
ActionScript3 source code
/**
* Copyright kihon ( http://wonderfl.net/user/kihon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6FZG
*/
package
{
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main()
{
addChild(new Board());
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
class Board extends Sprite
{
public static const WIDTH:int = 8; // 8 * 8マス
public static const HEIGHT:int = 8;
public static const SIZE:int = 30; // 1マスは30 * 30px
public function Board()
{
addEventListener(Event.ENTER_FRAME, draw);
addEventListener(MouseEvent.CLICK, onMouseClick);
}
// クリックされたとき
private function onMouseClick(event:MouseEvent):void
{
}
// 毎フレーム描画
private function draw(event:Event = null):void
{
graphics.clear();
for (var y:int = 0; y < HEIGHT; y++)
{
for (var x:int = 0; x < WIDTH; x++)
{
var tx:int = x * SIZE;
var ty:int = y * SIZE;
graphics.lineStyle(1.0);
graphics.beginFill(0xA0C000);
graphics.drawRect(tx, ty, SIZE, SIZE);
graphics.endFill();
}
}
}
}