16 Tips For Better Flash Development

Flash is capable of performing an impressive number of tasks and delivering such a wide variety of different types of information that it can be tricky to know where to start when trying to reign in a bloated application. In an effort to keep a large and still growing Flash application that I am developing under control, I recently did some research into Flash optimization. So, after some experimentation and a little searching around online, I was able to put together a list of tips, the best of which Ill share with you now. Some of these tips relate to graphics, most however, focus on the nitty-gritty of ActionScript and so are a little technical in nature.

1. Try not to scale images as this can be quite a CPU intensive operation.

2. Avoid using outlines around vector images, this also adds to CPU load without necessarily improving the quality of the vector.

3. Avoid using _alpha and gradients if possible. If you have an object thats going to be at 0 _alpha for a while, set '_visible = 0' instead.

4. Keep all your code centralized, because code lookups dont have to go through MCs. It also makes your SWFs far more intelligible if your code isnt hidden within a multitude of different MCs.

5. Reuse code where possible and practical. Try and avoid repeating routines where a single function might suffice.

6. Avoid unnecessary variable declaration. ActionScript is an interpreted language and variables take up more space than in compiled languages.

7. Use 'var' to declare variables. Local variables are faster to access for the player and are destroyed when the function returns.

8. When declaring variables, try and avoid long variable names, e.g. 'var thisisacrazylengthforavariablename = 1' is a lot slower than 'var shorter = 1'.

9. When declaring variables it is better to use 'var a=b=c=0' rather than:
'var a=0
var b=0
var c=0'

10. Defining things like parent in MC's as a local variable, e.g. 'var p=_parent', reduces the time taken for looking it up. Likewise, storing built in functions in vars can speed things up, e.g. 'var Mpi=Math.PI' , and precalculating whenever you can, e.g. 'var rad=Mpi/180'.

11. When using arrays, it's better to specify the initial size and make it sufficient for your needs. Otherwise flash will be resizing the array which wastes CPU power.

12. Avoid using multi-dimensional arrays, if a single dimension can be used instead.

13. Try not to operate on long strings, where possible, split the strings up.

14. 16000 is Flashs magic number. This number represents the upper limit for the number frames, layers, symbol instances and loaded movie clips within a given movie. Exceed this value, and Flash will start to act strange.

15. The supplied V2 components are large, inefficient and difficult to customize. If components are going to form the backbone of an application and will need to be customized, it may be worth investing in a third party solution.

16. A useful tool in battle with the bloat, is Flashs inbuilt size report. In the publish settings select the generate size report feature and review the output to see how the different parts of your SWF are contributing to file size.

These are just a few of the vast number of things that can be done to keep your Flash SWFs trim, and indeed may not be the best choice in all circumstances, but theyre a handy starting point nonetheless. A lot of the above tips were culled from the various resources catalogued at Lessrain blog; a site which is worth checking out for some further reading.

Cardinal Path

Share
Published by
Cardinal Path

Recent Posts

Google Delays Third-Party Cookie Deprecation to 2025

Google announced on April 23 that it will again delay third-party cookie deprecation (3PCD) in…

1 week ago

Understanding Funnel Reports in GA4

Funnel reports have long been one of the most actionable reports in a marketing analyst’s…

2 weeks ago

GA4 Monetization Reports: An Overview

GA4’s Monetization reports provide organizations with simple but actionable views into the revenue-generating aspects of…

2 weeks ago

This website uses cookies.