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: honeycomb

Get Adobe Flash player
by authergreil 04 Jun 2011
/**
 * Copyright authergreil ( http://wonderfl.net/user/authergreil )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2JpM
 */

// forked from Scmiz's honeycomb
package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            this.graphics.beginFill(0x000000);
            this.graphics.drawRect(0, 0, 465, 465);
            this.graphics.endFill();
        
            for (var y:uint = 0; y < 12; ++y) {
                for (var x:uint = 0; x < 10; ++x) {
                    drawHex(x * 52 + ((y % 2 ) * 26), 44 * y, 25, 0xffbb44);
                }
            }
        }
        
        private function drawHex(x:Number, y:Number, radius:Number, color:uint):void {
            
            this.graphics.beginFill(color);
            var num:uint = 6;

            var current:Number = Math.PI * 0.5;
            this.graphics.moveTo(x + (Math.cos(current) * radius), y + (Math.sin(current) * radius));
            for (var index:uint = 0; index <  num; ++index) {
                var next:Number = (Math.PI * 0.5) + (((index + 1) % num) * (Math.PI * 2 / num));
                this.graphics.lineTo(x + (Math.cos(next) * radius), y + (Math.sin(next) * radius));
            }
            this.graphics.endFill();
        }
    }
}