# Flash tiled map using spacial averaging. (AS2)

**URL:** <https://forum.kirupa.com/t/flash-tiled-map-using-spacial-averaging-as2/324623>\
**Category:** flash\
**Created:** [August 30, 2011, 8:00pm UTC](https://forum.kirupa.com/t/flash-tiled-map-using-spacial-averaging-as2/324623 "2011-08-30T20:00:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_Ingram](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Sam\_Ingram](https://forum.kirupa.com/u/Sam_Ingram)\
**Post date:** [August 30, 2011, 8:00pm UTC](https://forum.kirupa.com/t/flash-tiled-map-using-spacial-averaging-as2/324623/1 "2011-08-30T20:00:37Z")

</div>

I’m trying to make a tiled flash mapping programme using spatial averaging in AS2.

I have a function that fills the screen with random tiles.

I presumed that by running a second check where each tile checks its surround tiles and changes appropiately would work, but it only ever returns 3, 6 or 9 collisions regardless of the actual number.

Any ideas what’s wrong? This is what I tried:

function filterMap()  
{  
for (x = 0; x \< Stage.width; x += scale)  
{  
for (y = 0; y \< Stage.height; y += scale)  
{  
collisions = 0;  
for (j = -scale; j \<= scale; j += scale)  
{  
for (k = -scale; k \<= scale; k += scale)  
{  
if (tile[x + k, y + j] == tile[x, y])  
{  
collisions++;  
}  
}  
}  
if (collisions\< 6)  
{  
changeTile();  
}  
}  
}  
}
