Posts Tagged ‘Code’


Performance is a key ingredient to success of any application. This is a common factor for end-user to judge your application. Here I am listing some of the point that help us to improve the performance of ActionScript3 based application.

  • Always stay strongly typed
  • Avoid to using constants
  • For creating of instance of Array and Object instead of using constructor use [] and {}
  • _visible is better than _alpha
  • Must remove onEnterFrame and setInterval after use
  • Use int and bitwise operations
  • Carefully watch your Listeners
  • Avoid accessing variables of other classes directly
  • Use bitwise operator for multiplication and division
  • Keep in mind that division is slower than multiplication

 

Reference – http://help.adobe.com/en_US/as3/mobile/flashplatform_optimizing_content.pdf


As a developer we are habitual to use commonly used approach in programming. There are several alternate and optimized way are also available and we need to give a chance to them as well. ActionScript 3 introduced various operators for specifying how to combine, compare, or modify the values of an expression. From these operators we used only few common operators. There are several rarely used operator are in list that may provide an alternate and optimized way of programming.

There is an operator named logical OR assignment (||=) , this is not in a frequently use. The use of ||= operator is it assigns expression1 the value of expression1 || expression2. First see the traditional approach with the use of conventional operator. See the below example.

Using If condition

Using logical OR assignment operator (||=) we can optimize this.

Using logical OR assignment (||=) operator

In the above example you can see that the complete logical IF statement is shrink into one single line. This operator work like if object is initialized then use the same otherwise assign the newly created object. Enjoy! and give a chance for this operator in your programming.