Tutorial on Creating Following Objects.

Lesson 1 : Following Mouse W/O Ease.
Creating a movie clip :
Create new flash document.

Draw a circle using the oval tool.


Select the circle using double click. Press F8 to convert to symbol.

Part 1 :
Click on the circle and Press F9. Actionscript Panel will open. Insert the following actionscript.

Explanation about the code
_xmouse : returns the x coordinate of the mouse.
_ymouse : returns the y coordinate of the mouse.
_x : An integer that sets / stores the x coordinate of an object.
_y : An integer that sets / stores the y coordinate of an object.
variable diffx & diffy is used to store the distance between mouse's x & y cordinate and object's x & y cordinate respectively.
_x += diffx ;
Assigns _x , the value of _x + diffx .
_y += diffy ;
Assigns _y , the value of _y + diffy .
Part 2 :
replace
with
Explanation of code :
_x += diffx / 5 ;
Assign _x , the value of _x + diffx / 5 ;( dividing the diffrence with a number decreases the speed of movment. Higher the number lower the speed. )
_y += diffy / 5 ;
Assign _y , the value of _y + diffy / 5 ;( dividing the diffrence with a number decreases the speed of movment. Higher the number lower the speed. )
Create new flash document.
Draw a circle using the oval tool.
Select the circle using double click. Press F8 to convert to symbol.
Part 1 :
Click on the circle and Press F9. Actionscript Panel will open. Insert the following actionscript.
onClipEvent(enterFrame){
diffx = _root._xmouse - this._x ;
diffy = _root._ymouse - this._y ;
_x += diffx ;
_y += diffy ;
}
Explanation about the code
_xmouse : returns the x coordinate of the mouse.
_ymouse : returns the y coordinate of the mouse.
_x : An integer that sets / stores the x coordinate of an object.
_y : An integer that sets / stores the y coordinate of an object.
variable diffx & diffy is used to store the distance between mouse's x & y cordinate and object's x & y cordinate respectively.
_x += diffx ;
Assigns _x , the value of _x + diffx .
_y += diffy ;
Assigns _y , the value of _y + diffy .
Part 2 :
replace
_x += diffx ;
_y += diffy ;
with
_x += diffx / 5 ;
_y += diffy / 5 ;
Explanation of code :
_x += diffx / 5 ;
Assign _x , the value of _x + diffx / 5 ;( dividing the diffrence with a number decreases the speed of movment. Higher the number lower the speed. )
_y += diffy / 5 ;
Assign _y , the value of _y + diffy / 5 ;( dividing the diffrence with a number decreases the speed of movment. Higher the number lower the speed. )


