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

Random Tile

Get Adobe Flash player
by tkinjo 24 Mar 2011
    Embed
/**
 * Copyright tkinjo ( http://wonderfl.net/user/tkinjo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wpm8
 */

package  
{
    import flash.display.Sprite;
    
    [SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="60")]
    /**
     * ...
     * @author tkinjo
     */
    public class Main extends Sprite
    {
        private const NUM_TILE:uint = 10;
        private const BORDER_SIZE:uint = 1;
        
        public function Main() 
        {
            var tileSize:uint = ( stage.stageWidth / NUM_TILE ) - BORDER_SIZE;
            trace( tileSize );
            
            //graphics.beginFill( 0 );
            
            for ( var i:uint = 0; i < NUM_TILE; i++ )
                for ( var j:uint = 0; j < NUM_TILE; j++ )
                    drawRandomTile( i * ( tileSize + BORDER_SIZE ), j * ( tileSize + BORDER_SIZE ), tileSize, tileSize );
            
            graphics.endFill();
        }
        
        private function drawRandomTile( x:Number, y:Number, width:Number, height:Number ):void {
            
            graphics.beginFill( Math.random() * 0xffffff );
            
            graphics.drawRect( x, y, width, height );
            
            //graphics.endFill();
        }
    }

}