No bounce. Just snap
- Started
- Last post
- 13 Responses
- canadian
I have a circle MC. When the cursor is within 10 or 20 pixels from it, I need it to attach (snap) itself to the cursor tempting a user to click it. When that cursor moves outside of that 10 pixels space the circle should snap back to it's original position. No bounce. Just snap.
Anybody? Somebody? Help? I been at this all freakin day.
- canadian0
NO!
- vellan0
couldn't you just track the mouse, and when the mouse's x and y position are within ten, have it move to the x and y mouse position, and when they are further away, have it move back to the original x and y position...
yeah?
- canadian0
Yes vellan! But how?
- canadian0
come on vellan. dont fail me now.
- unfittoprint0
make an MC.onEnterFrame loop to check the mouse position (with some delay) and if the mouse goes > 10 pixels it stops following it.
- canadian0
more detailed? help? AS?
- vellan0
do you want us to write the actionscript for you?
- canadian0
Well, at least somewhat. I have searched and searched. I am just not that good at AS. I need some real help.
- canadian0
I cant take it anymore!
- unfittoprint0
damn, man, damn.
http://flashkit.com/search.php?c…
http://webforums.macromedia.com/…
You'll have to pick the scripts (follow and snap) from different exmples and join them (using for example a IF statement) depending on your objective.
do some research and try to find the solution. Come here tomorrow if you were not sucessfull.
good luck.
- ridiculous0
Find the distance using this:
a = x2 - x1;
b = y2 - y1;
distance = math.sqrt(a*a + b*b);Use a conditional inside of a frame loop or listener to check for distance between two objects (or mouse) and assign new _x _y values based on found value.
- canadian0
good leads. thank you guys!
- canadian0
Nothing.
I suck.