I am writing a script to detect when I collide one movie clip with another and add numbers to the score. I have the script working and it looks like this.
if (_root.cone1.hitTest(_root.car)) {
numHit +=1;
}
I want to increase the numer of items on the screen and thought I would try a for loop for a number of instances of the cone object ie
for (i=0; i<10; i++)
{
if (_root.cone1.hitTest(_root.car)) {
numHit +=1;
}
}
within this i need to replace cone1 with and identifier based upon the value of i. How do I do this and what is the syntax required.
Yep, it’s the rigth way to do it. Good idea with the reference too But you could declare it as a temporary variable (with “var”), as it is just used inside the loop.
You could numHit++, by the way. It’s nicer :beam:
he gave a suggestion; I gave a suggestion (which wasnt based off his and made the code messier and less nice - nice is good though)
Ill belittle him now though
the ?: if else structure isnt really appropriate in replacing just an if statement as ?: relates to “if not one then another” - the null being an unnecessary addition. Instead it could be just
for (i=0; i<10; i++) if (_root[“cone”+i].hitTest(_root.car)) numHit++;
which is actually better than my initial example because the addition is only executed when the hitTest is true and not for every loop of the for clause
but I still :love: ilyaslamasse emmensely
:flower:
[size=1]sorry lost[/size]
lol
[edit] That by the way is essensially what ilyaslamasse firs suggested with ++ just on onle line
sorry for posting here, i know it is not supposed to be posted here, but how can i get my footer up? Kirupa’s thread makes no sense, there is no link to Flash Footers at the top of any page… And if i post this in Help Forum, it will not be found
:-\ sorry about the post