# \[AS3\]Using bitmapData.draw and clipRect for tiles is problematic

**URL:** https://forum.kirupa.com/t/as3-using-bitmapdata-draw-and-cliprect-for-tiles-is-problematic/292910
**Category:** programming
**Created:** [July 20, 2009, 8:35pm UTC](https://forum.kirupa.com/t/as3-using-bitmapdata-draw-and-cliprect-for-tiles-is-problematic/292910 "2009-07-20T20:35:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![flashmxboy](https://avatars.discourse-cdn.com/v4/letter/f/779978/32.png) [@flashmxboy](https://forum.kirupa.com/u/flashmxboy)
#### Post date: [July 20, 2009, 8:35pm UTC](https://forum.kirupa.com/t/as3-using-bitmapdata-draw-and-cliprect-for-tiles-is-problematic/292910/1 "2009-07-20T20:35:37Z")

</div>

Hi again

I ran into some problems while splitting my big level into tiles.  
I use 10 bitmapData`s to split my level in 10 pieces and clipRect to draw only what i want to.  
So i use this code:  
[AS]var tile1:BitmapData = new BitmapData(grounder.width / 10,grounder.height,true,0x00FFFFFF);  
var tile2:BitmapData = new BitmapData(grounder.width / 10,grounder.height,true,0x00FFFFFF);  
//etc for the rest of the tiles  
//Then some clipRects:  
var tile1Rect:Rectangle = new Rectangle(ground.x, ground.y, ground.width/10,ground.height);

var tile2Rect:Rectangle = new Rectangle(tile1Rect.x + tile1Rect.width, tile1Rect.y, ground.width/10, ground.height);  
//Etc for the rest of the tiles  
//Then i draw out the first tile:  
tile1.draw(ground, null,null,null,tile1Rect);[/AS]

So far the code works fine:  
 ![](http://nettvei.com/correctDraw.JPG)  
but when i use this code to draw the next tile:  
[AS]tile2.draw(ground,null,null,null,tile2Rect,true);  
//I set a red square to indicate where the tile rectangle is  
redSquare.x = tile2Rect.x;  
redSquare.y = tile2Rect.y;  
redSquare.width = tile2Rect.width;  
redSquare.height = tile2Rect.height;[/AS]  
Then this happens:  
 ![](http://www.nettvei.com/wrongDraw.JPG)

Pretty strange huh?

This is the ground moveiclip im drawing:  
 ![](http://nettvei.com/actualDraw.JPG)  
Se any differences?😛

Anyway…what am i doing wrong?

Thanks in advance
