This content has been marked as final. Show 2 replies
I dealt a lot with this problem, as I am actually writing a game in Flex right now. Unfortunately, I can't name any one silver bullet... here are a few thoughts, though...
Obviously, keep un-needed elements off of the stage. I have a lot of familiarity with runtime optimization from working professionally in the video game industry, so it's easy for me to say this, but really it amounts to conserving variables and logic as much as possible. Think about WHEN something executes - simple tricks like knowing the order in which a compiler executes conditional logic can save you a lot of headache in the long run. Conserve your variables and just really try to think hard about if EVERY piece of data, individually, needs to be loaded at a certain point in time. Conserve the number of times you load images; use the Loader class to load the image (precache) and store the bitmap-data for later use.
For example, I had a big problem with lag on my map when I first wrote it; since it was tile-based, there was lots of trouble with all the tiles hidden from view and so on. My solution was multi-fold: first I fixed the number of tiles there were, so that there were just enough to cover the screen + a 2 tile buffer around the screen. Tiles which got pushed off the back end of the buffer would move themselves to the front of the buffer (wrapping around) so that new tile objects weren't being deleted/created repeatedly. I did away with the Image class and wrote my own bitmap drawing class, to keep it closer to the base Sprite class and get rid of excess crap. I stored each piece of image data externally and simply copied it into the display object as needed, rather than re-loading the data.
This, along with other things, has my game running at perfectly smooth speeds now, where once it was barely crawling.
I did a crash course in the psychology of web development and have removed a number of un-needed fields/animations from the site that users won't even notice.
One of the questions I've been meaning to ask though
I've got a object called "contentCanvas" to which my navigation effects.
Each navigation button is a custom class with a classname for the components which are loaded to the contentCanvas onclick (after .removeAllChildren of course)
Do these components sit in the ram or are thye only created when they are added as a child of the canvas,
Also, is the removed children removed entirely? How do i destory un-needed information in the ram? i want to removeallchildren, but i also want ot destroy the items so they are recompiled if called, rather than just stored.