Forums → Programming Forum → [as3]looping through array & splice
- 2 Replies
I normally use this method
for(var i:int = 0; i < array.length; i++)
but I have recently found that you can also do this
for(var i:int = array.length-1; i > = 0; i--)
What is the method you use the most? and why?
Looping forward or backwards. Or perhaps you have a different method for looping through arrays.
Assuming you are trying to organize collisions of objects. Would it be more efficient if the object itself could detect its own collision and remove itself from the program? you could use a Static variable to track any child of the class. that way.
If you want speed in this there might be a better data structure then an array.
I am doing some code cleanup and optimization, and am trying to find the best method to use.
I currently checking the collision in the game class. I can set it up to have the collision in the child using a static variable which I am already using. But what is most efficient method, I don't know.
I have not taken that route due to the mindset where if 2 children are detecting collision as soon as they collide, whichever is the first that is detecting the collision will be removed while the other will never detect it.
There are different route's to take and I would really like to see a prime example of a working method.
You must be logged in to post a reply!
We strive to deliver the best gaming experiences... on the internet and on your mobile phone. Play thousands of free online games, get access to free mmorpg games, online rpg games, fun online flash games, and more.
We offer free flash games in many different genres: online shooting games, online puzzle games, online war games, free online car games, free online hidden object games and dozens more.
This is the best place on the web to play online games for free... play on Armor Games! No matter what game style you prefer, we've got it here.
Gaming websites, passionate bloggers, and quirky streamers are welcome to share or review our games. If you need game keys, art, trailers, screenshots or more check out our press kit website.
Game developer? Visit developers.armorgames.com to request AG developer status, find documentation on our APIs, and get access to our development environment. Let's make sweet, sweet games together.
Looking for a publishing partner that can help your app rocket to success? Contact the mobile team to learn more about how we can help!