Why use init methods in AS3?

Init methodsChecking our stats, we noticed that some people are searching for “why use init methods as3”.

There are actually several reasons to consider using init methods in AS3 rather than having all of your initialisation code in your constructor functions:

  • Constructor functions run slower than “regular” methods. (See here for details.)
  • You might want to re-run initialisation code without recreating the instance.
  • You might want to run delayed initialisation code, for example once an object has been added to the Display List. (See our post here regarding this issue.)

Comments on this post

  1. jay says:

    thank you
    this is really helpful to me.
    have a nice day

Add a comment: