PDA

View Full Version : Code help



smack_boom
July 11th, 2005, 04:19 PM
Can anyone kinda break this script down for me and explain what it does?

_root.bullet_a = new Array(300);
for (var bulletnull = 0; bulletnull<300; bulletnull++) {
_root.bullet_a[bulletnull] = 0;
}
_root.debris_a = new Array(600);
for (var debrisnull = 0; debrisnull<600; debrisnull++) {
_root.debris_a[debrisnull] = 0;
}

lunatic
July 11th, 2005, 04:24 PM
Both do kind of the same thing. They each create a new array that resides on the main timeline. The first array holds 300 objects, then second array hold 600 objects.

Then each uses a for loop to cycle through numbers 0 to 299 (or 0 to 599) and sets each spot in the entire array(s) to zero.

So for example,
_root.bullet_a[0] = 0
_root.bullet_a[1] = 0
_root.bullet_a[2] = 0
.
.
.
.
_root.bullet_a[599] = 0

:hr:

smack_boom
July 11th, 2005, 04:25 PM
what would this be used for? Im an array newb :)

lunatic
July 11th, 2005, 04:26 PM
It's a fast way to load an array. We'd have to see more of the code to know what the array was for.

*edit* arrays are handy when you want to apply an action to a bunch of objects. So for example I could load an array with a whole bunch of movieclips and then set the whole array to be invisible instead of having to apply the invisiblity code to each individual movie clip.

smack_boom
July 11th, 2005, 04:45 PM
aah, i see thanks for the help lunatic

lunatic
July 11th, 2005, 06:15 PM
sho 'nuff :thumb:

kingofnukes
July 11th, 2005, 10:27 PM
If you post an fla. I might be able to help you.