Return to Snippet

Revision: 14775
at June 11, 2009 07:31 by sidneydekoning


Initial Code
// Snap object depending on the snapToSize
// Can be used for window dragging or in games etc.
// if the side of my square in my grid is 250, the snapToSize parameter would be 250. 
// If it is 100, the snapToSize parameter would be 100.

var snapToSize:int = 5;

snapClip_mc.x = mouseX - mouseX % snapToSize;
snapClip_mc.y = mouseY - mouseY % snapToSize;

Initial URL

                                

Initial Description

                                

Initial Title
Using modulo to snap an object

Initial Tags
object, math

Initial Language
ActionScript 3