TreeTree
TreeTree

Reputation: 3230

Which has better performance, symbols in the library or exported images of those symbols?

I recently chose to switch to a method where my library is totally empty and I embed every image/animation/sound that I need via the Embed tag because it would make my life easier. Having a lot of symbols in my library causes CS5 to run extremely slowly and it was really annoying me.

This was totally fine for making games for computers but I'm currently working on my first iPhone game and I'm noticing that the game starts lagging after a few seconds of play. It's not even a complex game but it does have a lot of images with transparency. So I'm wondering if it would run faster if I forget about the empty library method. I don't really know how that would affect performance but this is the first time that I have to worry about performance. But I am aware of other things that affect performance like transparency and object pooling (just read about this one).

Also the exact same game runs worse on an iPad even though it's a more powerful device?

Upvotes: 2

Views: 71

Answers (2)

divillysausages
divillysausages

Reputation: 8053

Having images in your library means that Flash will compress them when it exports the SWF/SWC. This may or may not be desirable.

Using the [Embed] tag means that you can compress them yourself in something like Photoshop and have complete control over the output.

You say that your "game starts lagging after a few seconds of play". This seems to be a memory/design problem rather than whether or not your images are embedded through code or as library symbols. Do some profiling to see where you're spending most of your time, and to check that you don't have a memory leak.

Upvotes: 1

weltraumpirat
weltraumpirat

Reputation: 22604

Both using the library and the [Embed] metatags influence performance of your IDE, but they are evaluated at compile time and will produce just about the same byte code.

The performance of your game at runtime is an entirely different issue, though you might be able to get good results by rethinking which images to embed as bitmaps and which to use as vector sprites, how to organize larger images (e.g. creating one basic player sprite and adding individual looks by composition, instead of making each player variation a full sized animation) and trying to reduce the use of transparency and alpha masks.

There are many good articles about improving ActionScript performance both on the AVM2 and on iOS devices. Try searching for "ActionScript optimization runtime" - it should yield plenty of results.

Upvotes: 1

Related Questions