Singleton's should work.  Some of the mx components even use this method so
it has to be possible.  Without looking at your code there's not really a
good way to guess why the values are being reset.

As for the private constructor, most singleton classes that come with docs
simply state not to call the constructor directly and if the programmer does
then he/she is either very smart or very stupid.  I've never tried, but you
could try to hack your way around it by setting a private static variable in
the getInstance() function, having the constructor check that variable,
throwing an error if it's not set, and then setting the variable back at the
end of getInstance().

Bottom line is that I wouldn't give up on the singleton idea.  It's probably
just one of those bugs that hides in plain sight.  Post the code or take a
break and try again later.

- Dan

On 26 Mar 2007 13:49:53 -0700, André Rodrigues Pena <[EMAIL PROTECTED]>
wrote:

  Hi all,

My problem is: I need some data classes to be global so that I can
access them without to have to establish unnecessary references.

I tried to create a Singleton class the way we're used to do in Java,
and I got 2 problems:

1) It's not possible to define a private constructor
2) The instance created in the getInstance() method is not keeping the
data, I don't know why

What do I do to have globally accessible structures in AS3?

--
André Rodrigues Pena

LOCUS
www.locus.com.br

Blog
www.techbreak.org

Reply via email to