PDA

View Full Version : Script slows down Flashplayer


Argon2k
11-24-2001, 12:18 PM
in the first frame i have this script. (This script should work.)
n = 0;
do {
n++;
if (n<=10) {
duplicateMovieClip ("box_fadeout", "box_fadeout"+(n), n);
setProperty ("box_fadeout"+(n), _x, 33+(n*44));
setProperty ("box_fadeout"+(n), _y, 150);
} else if (n > 20) {
duplicateMovieClip ("box_fadeout", "box_fadeout"+(n), n);
setProperty ("box_fadeout"+n, _x, 33+((n-20)*44));
setProperty ("box_fadeout"+n, _y, 150+(2*50));
} else {
duplicateMovieClip ("box_fadeout", "box_fadeout"+(n), n);
setProperty ("box_fadeout"+n, _x, 33+((n-10)*44));
setProperty ("box_fadeout"+n, _y, 150+(1*50));
}
} while (n<30);

2.Frame :

boxes = new Array["false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false","false"];
times = 1;

3.Frame :

proof = "false";
overrun = 0;
do {
r = random(30);
if (boxes[r] == "false") {
boxes[r] = "true";
proof = "true";
}
} while (proof == "false");
tellTarget ("box_fadeout"+r) {
gotoAndPlay (2);
}
times++;

4.Frame :

if (times < 30) {
gotoAndPlay (3);
}
stop ();

When i try to run the script, i get an errormessage that a script would slow down the Flashplayer!!!

pixelwit
11-27-2001, 04:56 AM
Be sure to change ALL frames to reflect the code provided below. It may look the same, but it's not.

FRAME1:
n = 0;
while (n<30) {
n++;
if (n<=10) {
duplicateMovieClip ("box_fadeout", "box_fadeout"+(n), n);
setProperty ("box_fadeout"+(n), _x, 33+(n*44));
setProperty ("box_fadeout"+(n), _y, 150);
} else if (n>20) {
duplicateMovieClip ("box_fadeout", "box_fadeout"+(n), n);
setProperty ("box_fadeout"+n, _x, 33+((n-20)*44));
setProperty ("box_fadeout"+n, _y, 150+(2*50));
} else {
duplicateMovieClip ("box_fadeout", "box_fadeout"+(n), n);
setProperty ("box_fadeout"+n, _x, 33+((n-10)*44));
setProperty ("box_fadeout"+n, _y, 150+(1*50));
}
}

FRAME2:
boxes = new Array("false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false", "false");
times = 0;

FRAME3:

r = Math.ceil (Math.random ()*30);
if (boxes[r] == "false") {
boxes[r] = "true";
times+=1;
tellTarget ("box_fadeout"+r) {
gotoAndPlay (2);
}
}

FREAME4:
if (times<=30) {
gotoAndPlay (3);
} else {
stop ();
}


Something you might want to read up on:
Array (object) // how to properly declare an array
Array.push // to easily add 30 elements to your array
Array.splice // to remove array elements after they have been used
while - doWhile // learn when to use which
boolean values // so you don't have to use strings "True" and "False"
Math.random // the right way to declare a random number
Math.ceil // to round a number up.

I'm pretty sure this script won't do exactly as you're hoping, but at least it will run now. I hope this helped.

-PiXELWiT
http://www.pixelwit.com