views:

72

answers:

1

I created a Flash room editor for an online game. The user is able to add items to their room, which the flash loads in and creates an object for each item. For the average user this works great, but I have run across a case where a user has added 8400 items to a room and the flash can't handle it. The XML file loads up fine, but nothing shows up when it tries to load into flash. I assume this is because flash runs into a wall trying to load all of that into memory? Is there any possible way to get around this, or do I just need to limit the amount of items put into a room (2500 was about the limit I found to work).

The editor was made with Actionscript 3 if that matters.

A: 

Well, I guess you will never show all 8400 items simultaneously, so I would advise you to load them on demand, and then unload the ones that are not showed anymore. I guess you could eventually store them all in memory as ByteArrays (loading them with URLLoader instead of Loader), and then using Loader.loadBytes each time you need to show one.

Bear in mind that each graphical asset you show or keep in memory as such (BitmapData, Loader, etc...) will use much more RAM than if you store them as ByteArrays.

Cay
Well only loading on demand is not an option as they can all be seen. I can get the same effect with ByteArrays?
James Simpson
In theory yes, but bear in mind that all of this depends on the user's RAM capacity, and when Flash runs out of memory, it just stops creating DisplayObjects... So I would advice you to load only the necessary assets for each state of your application (say levels, or screens, etc...), and then properly dispose them once you stop using them.
Cay