This is just a small note for all of those who is still developing using AS2.
The complete DON’T for AS2 classes is:
Never ever do create objects of your members arrays in declaration. Create them in the constructor instead.
This is just a small note for all of those who is still developing using AS2.
The complete DON’T for AS2 classes is:
Never ever do create objects of your members arrays in declaration. Create them in the constructor instead.
Constructor is a method which is called when an object of a class is instanced.
Like in any programming language, in actionscript constructor must have the same name the class has.
Constructor, as a function, may take any number of parameters.
Which is very handy to pass to initialize the objects.
I would recommend using constructor parameters over calling any additional initializing methods.
Here is a good example of using constructors in ActionScript:
var myPoint:Point = new Point(0,0);
And I can give you a lot of such examples.
However, this article is about a particular case, passing parameters to a constructor of your class, which is inherited from (extends) MovieClip.