I'm new to this site, but not really new to flash. Wasn't quite sure where to post this question so I figured here was as good as any. If I'm in the wrong section, please let me know I don't want to confuse anyone. Any help at all is appreciated as I've been struggling with this problem for a while now. Ok, so here goes...
The Program: I've been designing and programming a flash game from scratch ever since October. It started out as my senior project and has since turned into a long and drawn out process. Of course that is to say, I've been doing everything by myself and I also have a full-time job at night. Therefore the production schedule is rather non-existent. I work on it when I have the time and patience to deal with developing bugs. I code everything in ActionScript 3 and nothing is coded into any of the frames on flash, all graphics are images that are imported after I made them in a separate program. They are mostly *jpgs and *pnps. The game is structured so that I have a multiple class set up, such as a main, enemy, avatar, and projectiles class. If more info is needed I will provide, but that should give most a basic understanding of what I'm doing. So with that said...
The Situation: A few months ago I noticed the game dragging a lot. Once the "enemies" start accumulating on screen. I judge this, in part, was due to the real-time creation and deletion of enemies. After doing a general search on optimization techniques it occurred to me to try and "pre-render" a set number of enemies to use over and over, thereby decreasing the strain on flash to "reassemble" new enemies from scratch every time. As per the norm, the main class judges when to add enemies and respawn the player and such. The way I have this set up is a set number of enemy objects are created right away and the attributes are passed to an object array to keep track of locations and states and what not. When an enemy is called there is a search done of the object array to determine which type of enemy is needed and it's ID is returned. The ID is then passed to another public variable that the enemies class then checks to determine which enemy is being called, which then changes the state of the enemy with that particular ID corresponding. Now, ya got all that?
The (Current) Problem: For one, the game still lags horribly, and now the enemies aren't even working correctly. I've run tracers on the enemies and discovered that even though only one enemy ID is called, several of the "inactive" enemies turn up as "active". This may not be the cause of the lag, but it may be why the enemies are not "behaving" correctly. This bug is one I consider to be an error simply because I cannot figure out why multiple enemies are active when the tracers show only one enemy is singled out.
So if anyone has any ideas as to why I'm having this problem, please don't hesitate to contact me or respond. Again I appreciate any help at all. Thanks again.
J aka "Onyx"