Friday, August 27, 2010

Flash follow mouse tutorial

For those interested in flash as2 haere is another great tutorial for creating a object/mouse follow effect for advanced cursor visuals.

In the tutorial you create a movie clip symbol. This is important since this type of action script requires that you use movie clips.

then place an instance of the symbol on the main stage. It is good practice to add an instance name, however it is not required for this to work.

then apply this code to the instance:

onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;

The x and y refer to the placement of the object on the stage in relation to the mouse, whilst the speed determines its reaction time speed to the mouse movements.
The lower the number the faster it will react.

This is the link to the tutorial I did to learn this:

No comments:

Post a Comment