Comments on: Proper private constructors for ActionScript 3.0 https://blog.berniesumption.com/software/private-constructors-for-actionscript/ Various writings on software development and photography Fri, 10 Aug 2018 08:19:11 +0000 hourly 1 https://wordpress.org/?v=4.9.11 By: Bad... very bad. https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-564 Tue, 10 Dec 2013 11:50:57 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-564 class Singleton {
public function Singletor(lock:Class) {
if(lock != PrivateConstruct) throw new Error…
}
}
class PrivateConstruct {}

]]>
By: Flex Expert https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-563 Sat, 23 May 2009 21:17:54 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-563 Great trick !

Nice job !

]]>
By: cdude https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-562 Tue, 31 Mar 2009 09:30:22 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-562 cool trick. Thanks for sharing. I was looking for a way to do the private constructor singleton thing in AS3 like I did AS2 – while not perfect, this will certainly do the trick. :)

]]>
By: bernie https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-561 Thu, 29 Nov 2007 18:20:49 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-561 True. Old school JavaScript was a great language for hacking language features, from automagical memoization to AOP, if you understood it well enough. This just carries on in the same tradition.

]]>
By: Eric Feminella https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-560 Thu, 29 Nov 2007 18:13:17 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-560 The lack of actual Language constructs is a frustrating limitation of ActionScript 3, however, the limitations are helpful in that they force us to dig down a little deeper into the language to find what we can use to develop creative solutions to these limitations. It’s a fun challenge.

I also wrote a post awhile back which explains a way to create Abstracts in AS3 which you guys might find helpful as well.

http://www.ericfeminella.com/blog/2007/01/16/pseudo-abstract-classes-in-as3/

]]>
By: bernie https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-559 Thu, 29 Nov 2007 17:14:16 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-559 Awesome, that Eric Feminella version is exactly what I needed; it is better than my solution anyway, if not as good as real private constructors.

]]>
By: shaun https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-558 Thu, 29 Nov 2007 17:05:53 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-558 hey, just stumbled across this post:

http://www.darronschall.com/weblog/archives/000274.cfm

an interesting read, with links to other interesting reads :)

]]>
By: shaun https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-557 Wed, 28 Nov 2007 20:58:50 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-557 haha! i know what you mean!

]]>
By: bernie https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-556 Wed, 28 Nov 2007 18:43:45 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-556 Oops! good spot, fixed now. I’ve been going all int happy since AS3 came out, I forget that floating point numbers exist sometimes.

]]>
By: shaun https://blog.berniesumption.com/software/private-constructors-for-actionscript/#comment-555 Wed, 28 Nov 2007 18:36:13 +0000 http://www.berniecode.com/blog/2007/11/28/proper-private-constructors-for-actionscript-30/#comment-555 nice one! i’ve seen quite a couple of solutions to this problem, but i like the creativity of yours! surely the enforcer should be a Number though – casting the result of Math.random() to an int will always give you 0, rendering the enforcer useless ;)

]]>