PDA

View Full Version : Creating a "sticky effect"



innoxist
October 19th, 2004, 08:15 AM
I have an mc called "square", which is a square. It is placed in a grid, and follows the movement of the mouse. However, it stays in that square of the grid until the _x or _y of the mouse is half or more than halfway into the next grid square, so there's sort of a "sticky" effect.

Hope I'm coherent. Thanks for any help.

innoxist
October 19th, 2004, 08:39 AM
Sorry, I've thought out how already. Thanks anyway.

Gupps
October 19th, 2004, 02:26 PM
can you post an fla for me on how you achieve that effect

innoxist
October 20th, 2004, 01:38 AM
It's a totally diff method, but the effect is the same. Basically I have an mc of a square.

**Note: all of these are done WITHIN the mc**

On the first frame the square is white with a 1px black outline, on the second it is red with the black outline.

Then AS:
1st frame - stop();
2nd frame - stop();

Then on a new layer, the 1st frame:

this.onRollOver = function() {
gotoAndPlay (1);
};

this.onRollOut = function() {
gotoAndPlay(2);
};

On the stage arrange these mcs to form a grid. Very simple, but achieves the effect.

[m]
October 20th, 2004, 10:00 AM
or (with one mc):

onClipEvent(mouseMove){
this._x = Math.floor(_root._xmouse / this._width);
this._y = Math.floor(_root._ymouse / this._height);
}

And make sure that the center of the movieclip (indicated by a little plus-sign) is at the upper left corner of the square (by moving the square inside the mc).