Pay for Hesitation: Codes in Class Initializer

Pages

2010年3月5日 星期五

Codes in Class Initializer


public class A{

 //codes here.

 public function A(){ }

}

When ActionScript defines a class at runtime, it automatically creates a method named the class initializer and executes that method. In this class initializer, ActionScript places all the class's static variable initializers and all class-level code that is not a variable definition or a method definition.

Code in the class initializer runs in interpreted mode, and is not compiled by the JIT compiler. Because JIT-compiler code generally executes much more quickly than interpreted code, you should consider moving processor-intensive code out of the class initializer when performance is a priority.

沒有留言: