How to use Tilesheet and Sprites (and where did my events go?)

Hello everyone!

I’m learning how to use Tilesheets. I created an atlas (spritesheet) with arrows. Then I drew that arrow in a Sprite so I can add MouseEvent’s:

var tiles : Tilesheet = new Tilesheet(Assets.getBitmapData("img/sprites.png"));
 var left : Sprite = new Sprite();

 var id : Int = tiles.addTileRect(new Rectangle(0,0,64,128));

Well now there’s a catch. For the Flash target this works:

left.graphics.drawTiles(tiles, [0,0,id]);

However this code doesn’t work on native targets (including html5). The alternative is:

tiles.drawTiles(left.graphics, [0,0,id]);

Using any approach the MouseEvents attached to the Sprite stop working on all targets but Flash.

Strange, isn’t it?

I’ve found a workaround: before drawing the tile into the Sprite, you need to draw something:

left.graphics.beginFill(0xFFFFFF, 0.0); left.graphics.drawRect(0,0,64,128); left.graphics.endFill(); tiles.drawTiles(left.graphics, [0,0,id]);

Now the MOUSE_OVER and the MOUSE_OUT events work. I couldn’t use ColorTransform though.

Thanks for your time.

The same. Got this issue too