I am developing things for others as a template. However, because they dont know actionscript, my code has to be able to mend to what they have. One of the things I am doing is making a maze game. However, I am not specifying how many wall they must have. So therefore, if I use a hitTest, I wouldnt know how many to use. So I want to use an array and for loop. The idea is that they will enter the number of walls, and the for loop will go through all the walls and detect if they hit it.
For example, I thought it would go like:
// walls are named wall1, wall2, wall3, etc.
for (i=1;i<numberOfWallsVariable;i++){
if (this.hitTest(_root.wall)){
//what I want to happen
exit for;
}
}
This way if they had 4 walls, it would check to see if it hit any of the 4 walls and if it did, it would carry out the code. However, for some reason it doesnt work. I believe it is because instance arrays are different in actionscript than in other languages. Could someone tell me what I am doing wrong. Thanks in advance.
For example, I thought it would go like:
// walls are named wall1, wall2, wall3, etc.
for (i=1;i<numberOfWallsVariable;i++){
if (this.hitTest(_root.wall)){
//what I want to happen
exit for;
}
}
This way if they had 4 walls, it would check to see if it hit any of the 4 walls and if it did, it would carry out the code. However, for some reason it doesnt work. I believe it is because instance arrays are different in actionscript than in other languages. Could someone tell me what I am doing wrong. Thanks in advance.