Because of a visual components life cycle mainly. If I was to write an
application in actionscript (asside from the root mxml file - I don't think
you can do that in AS) all visual components would be initialised
immediatly.

Lazy loading is also used quite commonly as an OOP pattern.

Also constructor initialisation falls out of grace, (I think) with stuff
like spring in java as it doesn't allow well for dependency injection.

Finally Its just nice for people using your custom components if they act
like other components.  It means less to learn.

These are just opinions though I have mostly been writing my code in the
same way as you gave in the example. i.e.

private var someVar:someClass = new someClass();

Thanks for your help too though.  I did change my real class *not* the
simplified example to do that when I got your reply as I needed to get it
working quickly.

On Tue, Mar 10, 2009 at 8:05 PM, valdhor <valdhorli...@embarqmail.com>wrote:

> Why?
>
> Standard OOP practice is to initialize variables in the constructor (That's
> what it's there for).
>
>
> --- In flexcoders@yahoogroups.com, Wesley Acheson <wesley.ache...@...>
> wrote:
> >
> > Thanks I thought that always initialising either in the constructor
> > or in the variable declaration was a bit hacky.
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>

Reply via email to