If you create your first Singleton-instance, and from that class you
build up your application, the instance is not yet stored in the
variable. Therefore when other elements call its getInstance(), the
classvar hasn't been set yet. That's why your Singleton's constructor
gets called twice. My solution was this:
private static var $instance:ThisClass;
public function getInstance():ThisClass {
if (!$instance) $instance = new ThisClass();
return @instance;
}
private function ThisClass() {
if (!$instance) $instance = this;
init();
}
It's sloppy, but it works ;-)
Bart
2006/2/1, Manuel Saint-Victor <[EMAIL PROTECTED]>:
> Would a component that subclasses movie clip call its constuctor when
> dragged on stage despite the fact that the constructor is private. I'm
> getting a strange error wherein a supposed singleton class is calling the
> private constructor twice and therefore eliminating the references to it
> that other components had.
> I currently have the component subclassing the MoviClip class but am also
> trying to make it a Singleton. Will this not work?
>
> Mani
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders