Tutorial on Creating Following Objects.

Lesson 2 : Following with a trail effect
Click on circle and press F9 , to open actionscript panel , insert the following code :
onClipEvent(load){
_root.createEmptyMovieClip("line_mc" , -19000) ;
_root.line_mc.lineStyle(5, 0x0066CC , 100) ;
_root.line_mc.moveTo(this._x , this._y) ;
}
onClipEvent(enterFrame){
diffx = _root._xmouse - this._x ;
diffy = _root._ymouse - this._y ;
_x += diffx / 5 ;
_y += diffy / 5 ;
_root.line_mc.lineTo(this._x , this._y) ;
}
onClipEvent(mouseDown){
_root.line_mc.clear() ;
_root.line_mc.linestyle(5, 0x0066CC , 100) ;
_root.line_mc.moveTo(this._x , this._y) ;
}
Explanation of code :
_root.createEmptyMovieClip("line_mc", -19000) ;
Creates an empty movie clip at the root level , with the instance name line_mc at -19000 depth .
_root.line_mc.linestyle(5, 0x0066CC , 100) ;
Assigns a linestyle to movie clip line_mc , with the following parameters.
Thickness - 5 ;
RBG - 0x0066CC ;
Alpha - 100 ;
_root.line_mc.moveTo(this._x , this._y) ;
Moves the current drawing position to ball_mc's x & y coordinates .
_root.line_mc.lineTo(this._x , this._y) ;
Draws a line using the linestyle assigned , from the current drawing position to the coordinates mentioned .
_root.line_mc.clear() ;
Removes all the graphics created during runtime by using the movie clip draw methods , including the linestyles specified .


