General ActionScript 3 Guidelines
The following optimizations will increase AS3 execution speed.
- Always declare data type of a variable or a class member.
- Try to avoid declaring of variables and class members of type Object. Object is the most generic data type in AS3. Declaring a variable of type Object is the same as not declaring type at all.
- Try to avoid using of class Array. Use class Vector instead. Array is a sparse data structure. Unless you need to access/set value at index 4294967295 (or close) there is no need to use Array.
- Vector allows you to specify type of elements. Type Vector<*> means that you can store data of any type in an instance of this vector. Avoid using generic types like Vector<*>. Use specific types as elements of a Vector instead. For example Vector<int>, Vector<String>, or Vector<YourFavoriteClass> will use much less memory and will perform better than Vector<*>.
- Do not use Object as a hash table. Use class flash.utils.Dictionary instead.
- Avoid using of dynamic classes (and dynamic attributes). Access to dynamic attributes cannot be optimized at this time neither in Scaleform nor in Flash.
- Avoid using/changing of object's prototype. Prototype is a part of AS2. It is kept for compatibility in AS3, but in AS3 the same functionality can be achieved by using static functions and members.