# Snapping on predefined grid

**URL:** <https://forum.kirupa.com/t/snapping-on-predefined-grid/320884>\
**Category:** flash\
**Created:** [April 4, 2011, 8:21pm UTC](https://forum.kirupa.com/t/snapping-on-predefined-grid/320884 "2011-04-04T20:21:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chilldog](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@chilldog](https://forum.kirupa.com/u/chilldog)\
**Post date:** [April 4, 2011, 8:21pm UTC](https://forum.kirupa.com/t/snapping-on-predefined-grid/320884/1 "2011-04-04T20:21:35Z")

</div>

I’ve got a movie clip that’s basically a grid with small little boxes that total 84 rows, and 20 columns…

I’m trying to get the user to be able to snap to the y position of one of the small little boxes.

You click on a square, and position it over one of the small boxes in the grid, but it always snaps “wrong”. I’ve tried –

square\_on\_grid.y = Math.round(square\_y/g\_gridSpacing) \* g\_gridSpacing;

Where g\_gridSpacing is 12.5, the y value spacing of each small grid square cell.

Help!
