1  /**
     2   * com.sekati.draw.Tile
     3   * @version 1.0.0
     4   * @author jason m horwitz | sekati.com
     5   * Copyright (C) 2007  jason m horwitz, Sekat LLC. All Rights Reserved.
     6   * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
     7   */
     8  
     9  import flash.display.BitmapData;
    10  
    11  /**
    12   * Tiles a bitmap as wallpaper
    13   */
    14  class com.sekati.draw.Tile {
    15  
    16  	/**
    17  	 * create a tiled bitmap wallpaper
    18  	 * @param bitmap (String) export from library
    19  	 * @param target (MovieClip) clip to tile inside
    20  	 * @param w (Number) optional width to be tiled
    21  	 * @param h (Number) optional height to be tiled
    22  	 * @return Void
    23  	 * {@code Usage:
    24  	 * 	Tile.create(_level0, "bg_img", Stage.width, Stage.height);
    25  	 * }
    26  	 */
    27  	public static function create(bitmap:String, target:MovieClip, w:Number, h:Number):Void {
    28  		var pattern:BitmapData = BitmapData.loadBitmap( bitmap );
    29  		w = (!w) ? target._width : w;
    30  		h = (!h) ? target._height : h;
    31  		with (target) {
    32  			begineBitmapFill( pattern );
    33  			moveTo( 0, 0 );
    34  			lineTo( w, 0 );
    35  			lineTo( w, h );
    36  			lineTo( 0, h );
    37  			lineTo( 0, 0 );
    38  			endFill( );				
    39  		}
    40  	}
    41  
    42  	private function Tile() {
    43  	}
    44  }