<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AS3.0 Better Singletons</title>
	<atom:link href="http://blog.pixelbreaker.com/flash/as30-better-singletons/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.pixelbreaker.com/flash/as30-better-singletons</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 29 Dec 2009 06:37:44 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: estetik</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1283</link>
		<dc:creator>estetik</dc:creator>
		<pubDate>Wed, 03 Jun 2009 21:55:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1283</guid>
		<description>“Can I map “this” information?” Or
they ask, “Is there an application I can use on our network that I can
plot this info on?”</description>
		<content:encoded><![CDATA[<p>“Can I map “this” information?” Or<br />
they ask, “Is there an application I can use on our network that I can<br />
plot this info on?”</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cotton</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1287</link>
		<dc:creator>Cotton</dc:creator>
		<pubDate>Sun, 02 Nov 2008 01:06:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1287</guid>
		<description>We should keep the parameter list of construct clear.

package
{

public class Singleton
{

    private static var instance:Singleton;
    private static var isLock:Boolean = true;

    public function Singleton ()
    {
        if (isLock) throw new Error(&#039;ooops&#039;) else isLock = true;
    }

    public static function getInstance ():Singleton
    {
        return instance &#124;&#124;= (isLock = false, new Singleton());
    }

}

}</description>
		<content:encoded><![CDATA[<p>We should keep the parameter list of construct clear.</p>
<p>package<br />
{</p>
<p>public class Singleton<br />
{</p>
<p>    private static var instance:Singleton;<br />
    private static var isLock:Boolean = true;</p>
<p>    public function Singleton ()<br />
    {<br />
        if (isLock) throw new Error(&#8216;ooops&#8217;) else isLock = true;<br />
    }</p>
<p>    public static function getInstance ():Singleton<br />
    {<br />
        return instance ||= (isLock = false, new Singleton());<br />
    }</p>
<p>}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dimpiax</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1290</link>
		<dc:creator>dimpiax</dc:creator>
		<pubDate>Wed, 27 Aug 2008 12:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1290</guid>
		<description>This if pretty realisation of Singelton fo Me:

private static var __called : Boolean;
private static var __instance : Class;

public static function get instance() : Class {
    Class.__called = true;
    if(Class.__instance == null) Class.__instance = new Class();

    return Class.__instance;
}

public function Class() {
    if(__instance) throw Error(&#039;This class uses Singelton pattern.&#039;);
    else if(!__called) throw Error(&#039;You must access to class by Class.instance&#039;);
}</description>
		<content:encoded><![CDATA[<p>This if pretty realisation of Singelton fo Me:</p>
<p>private static var __called : Boolean;<br />
private static var __instance : Class;</p>
<p>public static function get instance() : Class {<br />
    Class.__called = true;<br />
    if(Class.__instance == null) Class.__instance = new Class();</p>
<p>    return Class.__instance;<br />
}</p>
<p>public function Class() {<br />
    if(__instance) throw Error(&#8216;This class uses Singelton pattern.&#8217;);<br />
    else if(!__called) throw Error(&#8216;You must access to class by Class.instance&#8217;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gabriel</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1291</link>
		<dc:creator>gabriel</dc:creator>
		<pubDate>Mon, 25 Aug 2008 12:06:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1291</guid>
		<description>would be a stupid developer to pass null.</description>
		<content:encoded><![CDATA[<p>would be a stupid developer to pass null.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1292</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 24 Aug 2008 06:01:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1292</guid>
		<description>The only problem with this solution is that a developer can simply pass null into the constructor:

var s : Singleton = new Singleton(null);

You have to explicitly check the nullity and type of the parameter:

public function Singleton(enforcer:*=null){
     if(enforcer==null &#124;&#124; !(enforcer is SingletonEnforcer))
           throw new Error(&quot;FAIL!&quot;);
}</description>
		<content:encoded><![CDATA[<p>The only problem with this solution is that a developer can simply pass null into the constructor:</p>
<p>var s : Singleton = new Singleton(null);</p>
<p>You have to explicitly check the nullity and type of the parameter:</p>
<p>public function Singleton(enforcer:*=null){<br />
     if(enforcer==null || !(enforcer is SingletonEnforcer))<br />
           throw new Error(&#8220;FAIL!&#8221;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Handford</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1278</link>
		<dc:creator>Gabriel Handford</dc:creator>
		<pubDate>Tue, 02 Oct 2007 02:52:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1278</guid>
		<description>Shouldn&#039;t it be:

public static var get instance():Singleton { return getInstance(); }

and change all the instance to _instance (to avoid the conflict)?</description>
		<content:encoded><![CDATA[<p>Shouldn&#8217;t it be:</p>
<p>public static var get instance():Singleton { return getInstance(); }</p>
<p>and change all the instance to _instance (to avoid the conflict)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: robert shearing</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1277</link>
		<dc:creator>robert shearing</dc:creator>
		<pubDate>Mon, 20 Aug 2007 00:23:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1277</guid>
		<description>I discovered another implenentation by Daniel Hai on http://www.onflex.org/code/

The private static instance variable is instantiated on declaration. Simple and clean:


package
{
public class Singleton
{

private static var instance:Singleton = new Singleton();

public function Singleton()
{

if( instance ) throw new Error( &quot;Singleton and can only be accessed through Singleton.getInstance()&quot; );
}

public static function getInstance():Singleton
{
return instance;
}
}
}</description>
		<content:encoded><![CDATA[<p>I discovered another implenentation by Daniel Hai on <a href="http://www.onflex.org/code/" rel="nofollow">http://www.onflex.org/code/</a></p>
<p>The private static instance variable is instantiated on declaration. Simple and clean:</p>
<p>package<br />
{<br />
public class Singleton<br />
{</p>
<p>private static var instance:Singleton = new Singleton();</p>
<p>public function Singleton()<br />
{</p>
<p>if( instance ) throw new Error( &#8220;Singleton and can only be accessed through Singleton.getInstance()&#8221; );<br />
}</p>
<p>public static function getInstance():Singleton<br />
{<br />
return instance;<br />
}<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gabriel</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1276</link>
		<dc:creator>gabriel</dc:creator>
		<pubDate>Fri, 17 Aug 2007 06:55:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1276</guid>
		<description>Exactly, ECMA doesn&#039;t allow private constructors. The PrivateClass is outside the package so that i can only be accessed by code within the current .as file (if it was in the package{} I&#039;d assume it would be accessible elsewhere within the package.</description>
		<content:encoded><![CDATA[<p>Exactly, ECMA doesn&#8217;t allow private constructors. The PrivateClass is outside the package so that i can only be accessed by code within the current .as file (if it was in the package{} I&#8217;d assume it would be accessible elsewhere within the package.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unformatt</title>
		<link>http://blog.pixelbreaker.com/flash/as30-better-singletons/comment-page-1#comment-1275</link>
		<dc:creator>Unformatt</dc:creator>
		<pubDate>Thu, 16 Aug 2007 22:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pixelbreaker.com/flash/as30-better-singletons/#comment-1275</guid>
		<description>This is nice - I guess ECMA doesn&#039;t like private constructors? Any reason not to include the PrivateClass in the package?</description>
		<content:encoded><![CDATA[<p>This is nice &#8211; I guess ECMA doesn&#8217;t like private constructors? Any reason not to include the PrivateClass in the package?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
