For some reason I can’t seem to get it to work. The transparent pixels are showing up as solid white. Any ideas? :ponder:
private function getTileFromSheet (s:Number):Bitmap {
var tsize:int = 32;
var sheet:BitmapData;
sheet = new SpriteSheet();
var sheetColumns:int = sheet.width / tsize;
var col:int = s % sheetColumns;
var row:int = Math.floor(s / sheetColumns);
var rect:Rectangle = new Rectangle(col * tsize, row * tsize, tsize, tsize);
var pt:Point = new Point(0, 0);
**var bmd:BitmapData = new BitmapData(tsize, tsize, true, 0);**
** bmd.copyPixels(sheet, rect, pt, null, null, true);**
** var bmp:Bitmap = new Bitmap(bmd);**
** return bmp;**
}
private function drawTile (s:Number, xt:int, yt:int):void {
var bmp:Bitmap = **getTileFromSheet(s);**
var rect:Rectangle = new Rectangle(0, 0, tileSize, tileSize);
var pt:Point = new Point(xt * tileSize, yt * tileSize);
**canvas.bitmapData.copyPixels (bmp.bitmapData, rect, pt, null, null, true);**
}