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