Re: [Flashcoders] AS2 and Singleton woes ...

2006-06-29 Thread Julien Vignali

Stephen, you're singleton implemention looks odd to me.
I think it is confusing to access the singleton shared instance by using 
a "new" (which is normally used to create multiple instances of the same 
class...). I would advise you to follow the standard singleton 
implementation:


class Sampler{
  private static var dsInstance:Sampler;

  // private constructor
  private function Sampler(){
// some initialization code...
  }

  public static function getInstance():Sampler{
if (dsInstance == undefined) dsInstance = new Sampler();
return dsInstance;
  }
}


var sampler:Sampler = Sampler.getInstance();

--
Julien


Stephen Ford a écrit :

Hi,
 
My singleton is throwing +256 levels of error.

Below I will show the code from my .as file and from the .fla file:
 
- DateShaper.as -class Sampler{private static var dsInstance:Sampler;  // The master instance of this class public function Sampler(){getInstance();} 
 
public function getInstance():Sampler{trace("dsInstance: "+dsInstance);  if(dsInstance == null) 
{dsInstance = new Sampler();

}  return dsInstance;
} 
}

- myFile.fla -
var mySampler:Sampler = new Sampler();
 
If you can see what I am doing wrong, please let me know.
 
Thanks,

Stephen.___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] AS2 and Singleton woes ...

2006-06-28 Thread Grant Cox
I had that with my last post too, I got a bounce around 5-10 minutes 
later.  However, I received my message through the mailing list before 
the bounce arrived, so I assumed it had worked.



Stephen Ford wrote:

Sorry if you've read the same message from me three times.
 
I keep getting a reply from flashcoders@chattyfig.figleaf.com saying my email has

been bounced, but checking the archives shows that all three messages got 
through.
 
Can anyone read this (or my last 3, very similar posts) post?
 
Thanks,

Stephen.
 ___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


  

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] AS2 and Singleton woes ...

2006-06-28 Thread Steve Rachels

A total of four so far...

:-)

HTH,
Steve


Stephen Ford wrote:


Sorry if you've read the same message from me three times.

I keep getting a reply from flashcoders@chattyfig.figleaf.com saying my email 
has
been bounced, but checking the archives shows that all three messages got 
through.

Can anyone read this (or my last 3, very similar posts) post?

Thanks,
Stephen.


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] AS2 and Singleton woes ...

2006-06-28 Thread Stephen Ford
Sorry if you've read the same message from me three times.
 
I keep getting a reply from flashcoders@chattyfig.figleaf.com saying my email 
has
been bounced, but checking the archives shows that all three messages got 
through.
 
Can anyone read this (or my last 3, very similar posts) post?
 
Thanks,
Stephen.
 ___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] AS2 and Singleton woes ...

2006-06-28 Thread Stephen Ford
Hi,
 
My singleton is throwing +256 levels of error.
Below I will show the code from my .as file and from the .fla file:
 
- DateShaper.as -class Sampler{private static var dsInstance:Sampler;  
// The master instance of this class public function Sampler(){getInstance();} 
 
public function getInstance():Sampler{trace("dsInstance: "+dsInstance);  
if(dsInstance == null) 
{dsInstance = new Sampler();
}  return dsInstance;
} 
}
- myFile.fla -
var mySampler:Sampler = new Sampler();
 
If you can see what I am doing wrong, please let me know.
 
Thanks,
Stephen.___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com