Friday 5 October 2012

Dynamically loaded asset and asset format considerations in AS3

I use external loading for assets in flash for more then one reason
and there is no best way to do it it has to be a balance depending on
what you want to achieve.

There are two things to take into account when we talk about flash and graphics:
- .png and .jpg images require more RAM but lot less CPU time to process
- vector graphics are very light but require more CPU time

In flash applications that run in browser, the flash runtime is either
on a thread or child process of the browser and this means its
dependent on the browser for resources and not only. To much CPU used
by flash makes the application unstable especially in the frame rate
witch is very important for a game. Most CPU consuming parts in a
flash application are vector graphics and to many elements in the
display list and especially to many movieclips (movieclips have a
time-line witch makes them more processor intensive in use then
Sprites). These are some of the reasons way it is a good idea to avoid
having too many movieclips or too many vector graphics on the stage,
especially for FPS critical apps.

Another reason to use external loading assets is the size of the flash
file witch is important in web application for bandwidth reasons and
also to make it more difficult for someone to take the flash file and
use it. There is no way to prevent people from downloading the flash
file but if the flash file is only an empty container even if you
download it you cant use it. I also tend to use external loading and
less stuff imported from different programs directly into the library,
because from a design there is no need to use everything and big areas
of the same colour or even a lot of effects can be achieved directly
in flash and that can lower a lot the resource consumption.

As a conclusion each application has different needs and there is no
right way but generally and especially for web games i found that
using external assets and avoiding importing stuff from AI is a good
practise for application optimisation.

I agree loading screens/assets dynamically helps, but I don't think it
should be done for everything, especially the main screens. Its better
to load all the main required assets in the preloader as it makes the
app feel more responsive. Loading content dynamically would be more
suitable for screens like shops, awards, profiles; screens that not
every player session would necessary need to load.

No comments:

Post a Comment