00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS3 to AS2 Array 2018-01-04 17:10:57


I'm trying to use a for loop to add all instances of the MC clam_aee to the Array ground_clam_array, in order to preform a hitTest on any instances of clam_aee.

var ground_clam_array: Array = new Array();
for(var i = 0; 1 < numChildren; i ++){
if(getChildAt(i)is clam_aee){
ground_clam_array.push(getChildAt(i));
}
}

Unfortunately, i just had to switch my document from AS3 to AS2 in order to allow nested script, and now my checker has an issue with this code. I assume this means that AS2 can't use Child or Push. In any case, how can I achieve adding any instances of clam_aee to ground_clam_array in order to hitTest ground_clam_array MCs in AS2?

Response to AS3 to AS2 Array 2018-01-05 09:51:13


At 1/4/18 05:10 PM, Kreinen wrote: I'm trying to use a for loop to add all instances of the MC clam_aee to the Array ground_clam_array, in order to preform a hitTest on any instances of clam_aee.
for(var i = 0; 1 < numChildren; i ++){

There's an error in the condition; did you mean "i < numChildren" instead of "1 (one) < numChildren" ?

Unfortunately, i just had to switch my document from AS3 to AS2 in order to allow nested script,

Why's this? What nested script do you need that AS3 doesn't support but AS2 does?

and now my checker has an issue with this code. I assume this means that AS2 can't use Child or Push. In any case, how can I achieve adding any instances of clam_aee to ground_clam_array in order to hitTest ground_clam_array MCs in AS2?

AS2 does indeed support array.push(), but not getChildAt(). There's no specific way of getting child movieclips that I remember of in AS2; the most I can think of is performing a for loop through _root and checking if the type is "movieClip".


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature