At 8/29/05 11:36 AM, Rantzien wrote:
The code seems to be unnecessarily long though, but I never bothered to look it through.
This is a shortened version, just without quotes and with commas...
fps=30, secondsToRecord=2;
playbackArrayX=Array(), playbackArrayY=Array();
i=0, j=0;
recording=false, moved=false;
onEnterFrame = function () {
if (Key.isDown(Key.SPACE) && !recording) {
recording = true;
}
if (Key.isDown(Key.SHIFT) && recording) {
playbackArrayX[i] = "EOF";
recording=false, moved=true;
_x=playbackArrayX[0], _y=playbackArrayY[0];
}
if (recording) {
if (Key.isDown(Key.LEFT)) {
_x -= 1;
} else if (Key.isDown(Key.RIGHT)) {
_x += 1;
}
if (Key.isDown(Key.UP)) {
_y -= 1;
} else if (Key.isDown(Key.DOWN)) {
_y += 1;
}
playbackArrayX[i]=_x, playbackArrayY[i]=_y;
i++;
if (playbackArrayX.length>fps*secondsToRecord
) {
playbackArrayX.shift(), playbackArrayY.shift();
i--;
}
} else if (!recording && moved) {
_x=playbackArrayX[j], _y=playbackArrayY[j];
j++;
if (playbackArrayX[j] == "EOF") {
_x=playbackArrayX[0], _y=playbackArrayY[0];
j = 0;
}
}
};
40 Lines
Probably best to use the longer one, so you can read through the comments and see what everything is doing.