Webgoblin
05-31-2005, 03:39 AM
Hi all,
I'm working on a project at the moment which is basically making a couple of components.
Now it'd be really handy if I could use a singleton class inside the component so that all the other classes within that component can just reach out with a SingletonClass.getInstance().doYourStuff() kind of call, and away we go. :cool:
I figure that since it gets compiled into a swc file, no worries, right?
Well, apparently not. :eek:
It turns out that if you stick two or more of those components on the stage at the same time, they ALL end up using the same instance of that class, not just the one that stupid me thought was packaged in its own little SWC file. :confused:
So, 1) can anyone confirm my explanation is correct?
and 2) can anyone suggest a 'how to' build a component-local singleton class?
Otherwise, I'm gonna have to hook up all those classes to instance stored in a property somewhere. And that would just about bugger my day!
:mad:
Thanks all for taking the time out to help.
I'm working on a project at the moment which is basically making a couple of components.
Now it'd be really handy if I could use a singleton class inside the component so that all the other classes within that component can just reach out with a SingletonClass.getInstance().doYourStuff() kind of call, and away we go. :cool:
I figure that since it gets compiled into a swc file, no worries, right?
Well, apparently not. :eek:
It turns out that if you stick two or more of those components on the stage at the same time, they ALL end up using the same instance of that class, not just the one that stupid me thought was packaged in its own little SWC file. :confused:
So, 1) can anyone confirm my explanation is correct?
and 2) can anyone suggest a 'how to' build a component-local singleton class?
Otherwise, I'm gonna have to hook up all those classes to instance stored in a property somewhere. And that would just about bugger my day!
:mad:
Thanks all for taking the time out to help.