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

--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> They would be the same.
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of lytvynyuk
> Sent: Tuesday, March 25, 2008 12:21 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Singletone class in Application and Modules !?
> 
>  
> 
> Is it true if I have singleton class instantiated in main application
> and in module, instances will be different?
> 
>     public class DataManager
>     {
>         private static const singleton_:DataManager = new DataManager();
>         
>         public static function get instance():DataManager {
>             return singleton_;
>         }
>         
>         public function DataManager() {
>             if (singleton_ != null) {
>                 throw new Error("Cannot instantiate singleton
> DataManager");
>   !          }
>         }
>     }
> 
> in main application:
> 
>       private function init():void {
>           this.dataManager = DataManager.instance;
>       }
> 
> in module 
> 
>       private function init():void {
>           this.dataManager = DataManager.instance;
>       }
>


Reply via email to