Hi, the animation that I'm trying to build is probaly very simple, but I can't quite work it out?
What I'm trying to make is a basic drag and drop where the object ('dragt') slowly returns to it's starting point by following the target ('targett') in order to get there.
The problem is that the function I'm using to move it there ('movet' = pasted in below) keeps going. So that when you try to click on it again, it's still working and it causes a flickering between the movement it's trying to accomplish and the drag action.
I tried including a variable ('ton') to build in a basic on/off state into the function, so that it won't work until 'ton == 0', ton is made equal to 0 as part of the start drag action. However, as said, this only works once as the function is still going when you go back to click again. So the hitest (seen below) registers again and puts 'ton == 1' before the drag can even begin.
So... what I need is some way to tell the function to stop doing what it's doing when the movieclip returns to it's original co-ordinates?
Hopefully I'm explaining this in some way that makes a degree of sense and somebody can solve this, or has encountered something similar before,
thanks loads,
-Eoin McD
Here's the function:
setInterval(movet, 5);
// call the catchase function every 5 ms
function movet() {
// set x, y for cat closer to x, y of mouse
if (_root.ton == 0) {
_root.dragt._x = _root.dragt._x+(_root.targett._x-_root.dragt._x)/20;
_root.dragt._y = _root.dragt._y+(_root.targett._y-_root.dragt._y)/20;
}
if (_root.dragt.hitTest(_root.targett)) {
_root.ton = 1;
}
if (_root.ton == 1) {
gotoAndStop(1);
}
}
updateAfterEvent();
