In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: 四角を敷き詰める。

Get Adobe Flash player
by meika_kouri 01 Apr 2011
    Embed
/**
 * Copyright meika_kouri ( http://wonderfl.net/user/meika_kouri )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cBcU
 */

// forked from meika_kouri's 四角を敷き詰める。
package {
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var squeres:Vector.<Shape> = new Vector.<Shape>();
            var line:Number = 4;
            var gap:Number = 2;

            var rowCount:int = 70;
            var colCount:int = 70;
            var centerX:Number = stage.stageWidth / 2;
            var centerY:Number = stage.stageHeight / 2;
            
            //同じ四角をVectorに入れて位置をずらす
            for(var i:uint = 0; i < rowCount; i++){
                for(var j:uint = 0; j < colCount; j++){
                    var nowIndex:uint = i * colCount + j; //左上から横優先
                    squeres[nowIndex] = drawSquere(line);
                    //画面中央基準なのでカウンタから10引く
                    squeres[nowIndex].x = centerX + (j - colCount / 2) * (line + gap); 
                    squeres[nowIndex].y = centerY + (i - rowCount / 2) * (line + gap);
                    addChild(squeres[nowIndex]);
                }

            }

         }
        
        //中央を基準点にした四角Shape。
        private function drawSquere(line:Number):Shape{
            var harfLine:Number = line / 2;
            var squere:Shape = new Shape();
            var g:Graphics = squere.graphics;
            g.beginFill(0x00FFFF);
            g.moveTo(-harfLine, -harfLine);
            g.lineTo(harfLine, -harfLine);
            g.lineTo(harfLine, harfLine);
            g.lineTo(-harfLine, harfLine);
            g.lineTo(-harfLine, -harfLine);
            
            return squere;
                    }

    }
}