// simplest way, but it has a problem
// the movie clip will never reach it's destination and will never stop going
movieclip_mc.onEnterFrame = function(){
movieclip_mc._y += .2 * (newPosition - movieclip_mc._y);
}
// this is how you can snap it into place and stop animating
movieclip_mc.onEnterFrame = function(){
// if the distance between where the mc is and where it's going is less than 1...
if(Math.abs(newPosition - movieclip_mc._y) < 1){
movieclip_mc._y = newPosition; // then snap the mc to it's new position
delete(this.onEnterFrame); // then delete the "onEnterFrame" cuz you don't need it
}else{
movieclip_mc._y += .2 * (newPosition - movieclip_mc._y); // keep going if not
}
}
Showing posts with label animate. Show all posts
Showing posts with label animate. Show all posts
Friday, July 13, 2007
Subscribe to:
Posts (Atom)