Kabomb > Tutorials > Cursor Effects
Introduction
Introduces you to linking from the library and at the same time shows you how to make cool cursor effects.
The Code
Firstly create a new blank MC called 'effect', and inside it create a simple animation of anything you want, as long as it has a start and a finish, noting that the centre of the mc will be the position of the mouse at the start of the animation. I made a shape tween of a circle that starts at the centre, then moves out and gets smaller before finishing. On the last frame, add this code:



This deletes it because you don't need it anymore.

Go onto the main timeline, and add this code:


Explanation
Also, in the library, right click or ctrl-click on the effect, then go to linkage, and check the 'export for actionscript' box. In the identifier textbox, type effect if it's not already there and click ok. By doing this, you created a link between the actionscript and the MC, so without it being on the stage you can use actionscript to make a MC appear.

Now back to the code, on the first line you create a new MC that will hold all effect MCs. You do this so you can set the depth of the effects under or over any other MCs that you want.

You'll create an effect every frame, so firstly in the onEnterFrame function you set a variable 'id' to the effects_mc next highest depth. So if I had 5 effects there, the next highest depth would be 6. You then create a new MC and attach the MC from the library into the effects_mc MC. attachMovie consists of:

attachMovie(idName, newName, depth)

Where idName is the linkage name you gave it in the library, newName is obviously the newName, but we add id so that each effect is original, and the depth is where it appears (on top or under) which is also set to id.
Then you set the effect's x and y positions to the mouse's positions. The last line creates a random rotation for the effect. Math.random() generates a random number from 0 to 1, 0 inclusive but it cannot be 1. By multiplying it by 360, you make the range from 0 to 360.

Conclusion
That's how simple it was, now test the movie.