This tutorial will show you how to move a object to a specified point. This has a lot of uses in gaming and other things.
Let's start. 1.Create a movieclip object of your choice. Here I created a amoeba object I gave it a instance name of "amoeba". 2.Create a mouse cursor . I created a movieclip with a red square , I gave it a instance name of "point". 3.Now comes the actionscript put the below code in the first frame.
//x,y are x and y axia position //xl,yl are last position of movieclip //xi,yi are x and y incremental values x=amoeba._x;y=amoeba._y; function pos() { xl = amoeba._x; yl = amoeba._y; xi = xl - x; yi = yl - y; xi = xi/150 yi = yi/150 if(yi < 0){yi = -yi;} if(xi < 0){xi = -xi;} } function animate() { pos(); if(amoeba._x >= x){amoeba._x -= xi;} if(amoeba._y >= y){ amoeba._y -= yi;} if(amoeba._x <= x){amoeba._x = xi;} if(amoeba._y <= y){ amoeba._y = yi;} } setInterval(animate,10); point.onMouseDown=function() { x = this._x; y = this._y; } point.onEnterFrame = function() { startDrag("point",true); }