I have often seen an init() within the constructor of AS3 classes, sometimes even being the only code in the constructor. Why would it be useful to do this, if you could si
Programmers new to AS3 often have problems referencing the stage (the well known 'it's not there' situation).
By doing ... :
public function ClassName()
{
super();
addEventListener( Event.ADDED_TO_STAGE, init, false, 0, true );
}
private function init( event : Event ) : void
{
removeEventListener( Event.ADDED_TO_STAGE, init );
// Reference stage.stageWidth;
// Call init after some sort of load completion initialized in the constructor
}
... it's easily fixed.
Or sometimes you initialize an XML loader in the constructor, and then call the initialize function upon load completion.