I have this amusing script, forgot where it came from, that generates some random movement. It works exported as flash6 as2.0, but is broken in flash7 and up export. Wondering if someone could take a peak and see what the problem is. Thanks very much.
Fla. attached, but this AS just sits on an mc called queenBug.
[INDENT]//Create the mosquitoes
onClipEvent (load) {
// Number of mosquitoes
num = 6;
// Speed of flight (higher=faster)
maxVel = 2;
// Set the limits of the stage
topLim = 0;
botLim = 400;
leftLim = 0;
rightLim = 400;
// Turn off the main mosquitoe
queenBug._visible = false;
// Clone the main mosquito (num) times
for (i=1; i<=num; i++) {
queenBug.duplicateMovieClip(“bug”+i, i);
bug = this[“bug”+i];
bug._x = random(rightLim);
bug._y = random(botLim);
}
}
// Random movement code: Modify to acheive various results
onClipEvent (enterFrame) {
for (i=1; i<=num; i++) {
bug = this[“bug”+i];
// Keep bugs within horizontal bounds (leftLim and rightLim)
if (bug._x-bug._width<leftLim) {
bug.xVel = random(maxVel)+2;
} else if (bug._x+bug._width>rightLim) {
bug.xVel = -(random(maxVel))-2;
} else {
bug.xVel = (random(100)>50) ? random(maxVel)+1 : -(random(maxVel))-1;
}
// Keep bugs within vertical bounds (botLim and topLim)
if (bug._y-bug._height<topLim) {
bug.yVel = random(maxVel)+2;
} else if (bug._y+bug._height>botLim) {
bug.yVel = -(random(maxVel))-2;
} else {
bug.yVel = (random(100)>50) ? random(maxVel)+1 : -(random(maxVel))-1;
}
// New bug location by a few random pixels dependent on speed variable maxVel
bug.xV += bug.xVel;
bug.yV += bug.yVel;
if (bug.xV>maxVel2) {
bug.xV = maxVel2;
} else if (bug.xV<maxVel*-2) {
bug.xV = maxVel*-2;
}
if (bug.yV>maxVel2) {
bug.yV = maxVel2;
} else if (bug.yV<maxVel*-2) {
bug.yV = maxVel*-2;
}
// Set new bug location
bug._x += bug.xV;
bug._y += bug.yV;
}
}
[/INDENT]