all groups > flash actionscript > march 2007 >
You're in the

flash actionscript

group:

Managing large arrays


Managing large arrays Tyler1128
3/1/2007 9:39:49 PM
flash actionscript:
Im creating a game that enemies come on to the stage that you shoot at. The
enemies and shots are attached into arrays and everytime a instance of eather
the "enemy" or "shot" comes onto the stage the array gets another attached to
the bottom of the array so it never runs out.
After the enemy "dies" or the shot exits the stage it gets deleted but the
array "slot" just turns to undefined so after a bit these arrays get large. I'm
then doing a hit test of every shot to every enemy in a loop. So when these 2
arrays get large, even if undefined the frame rate drops to nearly 0.
Each "enemy" has 5 other arrays with it with a matching number for speed,
health,experience,money, and damage so I'm wondering how to make these Arrays
small enough to run properly or a better way to create this with the same
results.
Re: Managing large arrays MotionMaker
3/2/2007 3:19:36 PM
Look at http://livedocs.macromedia.com/flash/8/main/00001917.html.

If the array element is the only reference to the clip, the clip should be
cleaned up by the garbage collector.

However if you are storing the index in other arrays, you have to adjust those
and thus a looped approach might be considered where you loop until you hit the
one to delete, then you copy the index element +1 to the current loop index.
Then use http://livedocs.macromedia.com/flash/8/main/00001909.html to remove
the last index.
AddThis Social Bookmark Button