You should probably implement the IMXMLObject interface. Override the
initialized method where you can set the class instance (to 'this').

The getInstance() method can create a default class instance if it's null
and return it.

Don't save references to the class instance in the classes that need to use
it. Instead always call getInstance(). This way, until the MXML singleton is
initialized, a 'default' singleton will be used. Afterwards, the MXML
instance will be used.

This said, why do you need the singleton to be MXML?

Haykel Ben Jemia

Allmas
Web & RIA Development
http://www.allmas-tn.com




On Sat, Jan 10, 2009 at 5:47 AM, dorkie dork from dorktown <
[email protected]> wrote:

>   I'm stumped. I'm trying to create a singleton class that is also an MXML
> class.
>
> <managers:SingletonClass /> creates one instance obviously. But another
> class needs to reference this class. So class 2 calls
> SingletonClass.getInstance(). It's possible that class 2 will be created
> before the MXML SingletonClass instance.
>
> It's ok for me if there is a ghost instance as long as everything works
> like it should. As long as the instance that is in the main MXML file is the
> one thats in effect.
>
> Also, when debugging this, the id is always an empty string. I'm extending
> EventDispatcher.
>
> dorkie dork from singleton-town place
>  
>

Reply via email to