I am trying to implement this in my singleton. 

 

How, where is SingletonEnforcer implemented?

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Winscot
Sent: Wednesday, March 26, 2008 1:37 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Singletone class in Application and
Modules !?

 

I just looked at your source. You forgot to control the scope! Your
implementation should be:

package
{
public class DataManager
{
private static var singleton_:DataManager = new
DataManager();

public function DataManager( enforcer:SingletonEnforcer ) {
}

public static function getInstance():DataManager {

if ( singleton_ == null )
singleton_ = new DataManager( new SingletonEnforcer );

return singleton_;
} 
}
}

class SingletonEnforcer{}

If you do this... it doesn't/won't matter where you instantiate it.
There
can be only one - MUWUAHAHAHAA.

Rick Winscot

From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
Behalf Of lytvynyuk
Sent: Wednesday, March 26, 2008 1:28 AM
To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
Subject: [flexcoders] Re: Singletone class in Application and Modules !?

I figured out the case. I, actually, made first instance in another
module
not in main App. 
Conclusion is: if you make instance in your main app - everything works
fine. 
If you did it in one of modules, this and all others will get new
instances.
Very easy to see when put trace("BLAH") in the constructor. PS. do not
include your class, which suppose to be singleton in you main
application,
and then it will fail.

test included  >> testSingleton.zip 

>
> I beg to differ.  I had setup my app thinking this to be true.  When I
> did this the module would get it's own, and very different, instance
> of my singleton.  I had to change the way I did things so what I do
> now is upon loading my module, the main app then sets the singleton
> into the module.  I don't have my example code anymore, but it was
> quite easy to produce the results.
> 
> Maybe it has to do with the way I compiled my module????  I compiled
> my application with "-link-report=c:\app\encoreNG.link.report.xml" and
> my module with "-load-externs=c:\app\encoreNG.link.report.xml".  Not
> sure if that has anything to do with it.  Also, when I had this coded
> I was on Flex 3, Beta 3 and have not retested with Flex 3 GA.
> 
> Dale



 

Reply via email to