Mouse Cursor Recorder
| Category | : Flash | Views | : 38895 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : mouse-cursor-recorder.zip | ||
| Result | : See the result | ||||
This code will record all mouse movement inside your flash movie and then a copy of your mouse will repeat the movements.

Create three buttons: "Record", "Play" and "Stop"; and give an instance name to them, "recBtn", "playBtn" and "stopBtn".
Then create the mouse Movie Clip to simulate a "real" mouse:

Drag it to the stage with the instance name "mouseMC".
Now open the action in the main timeline and paste:
//make the mouse copy invisible
mouseMC._visible = false;
//we are not recording the mouse yet so its false
var recording = false;
//not playing the mouse
var playing = false;
//index for the arrays that will store the mouse movement
var index = 0;
//arrays for the x and y position of the mouse
var mPosX = new Array();
var mPosY = new Array();
_root.onEnterFrame = function()
{
//if we are recording we copy the mouse position to the arrays
if(recording)
{
//copy _x and _y coordinate
mPosX[index] = _root._xmouse;
mPosY[index] = _root._ymouse;
//increase index by 1 to use an empty position inside the arrays on the next frame
index++
}
//if we are playing what we recorded
else if (playing)
{
//set the mouse Movie Clip position to the coordinates inside the arrays
mouseMC._x = mPosX[index]
mouseMC._y = mPosY[index]
//increase index to move to the next position inside the arrays
index++;
//if we are at the last position of the mouse
if(index == mPosX.length)
{
//show the original mouse
Mouse.show();
//and make the copy invisible
_root.mouseMC._visible = false;
}
}
}
