Monday, May 21, 2007

Project 4: Simple Cursor Trail



The fading effect is accomplished by creating a fade to 0% shape tween inside the movie clip 'aniGuy'.

The Code:

depth = 0;
attachMovie("aniGuy","guy",depth++);
guy = _root["guy"];
guy._alpha = 0;
mouseListener = new Object();
Mouse.addListener(mouseListener);

this.onEnterFrame = function()
{
_root["guy"+depth].removeMovieClip();
_root.guy.duplicateMovieClip("guy"+depth,depth);

thisGuy = _root["guy"+depth];
thisGuy._x = _root._xmouse;
thisGuy._y = _root._ymouse;
thisGuy._alpha = 100;
depth++;
if ( depth > 10 )
{
depth = 1;
}
}


VARIATION: For a simple variation I added a line of code to tell the dragged movie clip to go to and stop on a specific frame. In this case I attached the frame number to the depth for ease.




The Code Bit:
...
thisGuy = _root["guy"+depth];
thisGuy.gotoAndStop(depth);
thisGuy._x = _root._xmouse;
thisGuy._y = _root._ymouse;
thisGuy._alpha = 100;
...

No comments: