RE: [Flashcoders] Abstract classes in AS3?
Hi, Regarding: - 2) Have methods which are not attached to specific class instances. That's a bit like static methods no ? I was incomplete. I should have said, Have *bundled* methods which are not attached to specific class instances. That is, I want to be able to have groups of static methods. Static classes are how this is currently accomplished, but if we can't have private constructors, there's no way to prevent someone from (pointlessly) instantiating a static class. Can methods be attached to packages in AS3.0? If so, that might help. - Yes, this can be done in AS 3.0. Note that the Flash IDE requires you to name your .as file with the same name as the function so that the IDE can find the definition. // foo/bar/MyFunction.as package foo.bar { public function MyFunction() { trace(MyFunction); } } // test.fla import foo.bar.*; MyFunction(); You can also define functions in the unnamed package. That way, you can use the function without the import statement as long as that function is in your classpath: // HelloWorld.as package { public function HelloWorld() { trace(Hello, World!); } } // test.fla HelloWorld(); -Nivesh QE Lead, Flash | Adobe Systems -- Message: 5 Date: Wed, 12 Jul 2006 09:16:41 -0700 From: Mike [EMAIL PROTECTED] Subject: RE: [Flashcoders] Abstract classes in AS3? To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=US-ASCII -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicolas Cannasse Sent: Wednesday, July 12, 2006 1:16 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? Mike Keesey wrote: I don't really care whether they allow private constructors or not, as long as they provide some way of accomplishing the same thing. Specifically, I want to be able to: 1) Limit the number of instances of certain classes (singletons, enumerations). Did you have a look at haXe enums ? http://haxe.org/ref#the_power_of_enum Sure, something like that would be nice. But it's not in AS3.0. 2) Have methods which are not attached to specific class instances. That's a bit like static methods no ? I was incomplete. I should have said, Have *bundled* methods which are not attached to specific class instances. That is, I want to be able to have groups of static methods. Static classes are how this is currently accomplished, but if we can't have private constructors, there's no way to prevent someone from (pointlessly) instantiating a static class. Can methods be attached to packages in AS3.0? If so, that might help. 3) Be able to create classes that cannot be instantiated themselves but can be superclasses of concrete classes. Yes, I agree there. Removing the ability to create private constructors seems completely pointless. The rational behind it seems a bit like you don't need that, which is not a very strong point IMHO. Exactly! Replace the removed functionality with some other strategy, but don't just get rid of it and pretend nothing's wrong. -- Mike Keesey ___ 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] Abstract classes in AS3?
2) Have methods which are not attached to specific class instances. That's a bit like static methods no ? I was incomplete. I should have said, Have *bundled* methods which are not attached to specific class instances. That is, I want to be able to have groups of static methods. Static classes are how this is currently accomplished, but if we can't have private constructors, there's no way to prevent someone from (pointlessly) instantiating a static class. Got it. It's not in AS3, but haXe have both private contructors and the simple possibility to NOT provide a constructor (in that case the class can't be instanciated). Nicolas ___ 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] Abstract classes in AS3?
Where can I find the source code of HaXe written in HaXe itself. I think is one of the important milestones for a compiler, the possibility to compile the compiler with itselves :) Not always. The AS3 compiler is not written in AS3. Haxe is using OCaml which is IMHO the best language to write compilers. Since haXe is opensource, you can download them from http://haxe.org Nicolas ___ 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] Abstract classes in AS3?
I don't really care whether they allow private constructors or not, as long as they provide some way of accomplishing the same thing. Specifically, I want to be able to: 1) Limit the number of instances of certain classes (singletons, enumerations). Did you have a look at haXe enums ? http://haxe.org/ref#the_power_of_enum 2) Have methods which are not attached to specific class instances. That's a bit like static methods no ? 3) Be able to create classes that cannot be instantiated themselves but can be superclasses of concrete classes. Yes, I agree there. Removing the ability to create private constructors seems completely pointless. The rational behind it seems a bit like you don't need that, which is not a very strong point IMHO. Nicolas ___ 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] Abstract classes in AS3?
Yeah, well I don't need the onion skinning tool either so let's remove it ;-) ___ 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] Abstract classes in AS3?
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nicolas Cannasse Sent: Wednesday, July 12, 2006 1:16 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? Mike Keesey wrote: I don't really care whether they allow private constructors or not, as long as they provide some way of accomplishing the same thing. Specifically, I want to be able to: 1) Limit the number of instances of certain classes (singletons, enumerations). Did you have a look at haXe enums ? http://haxe.org/ref#the_power_of_enum Sure, something like that would be nice. But it's not in AS3.0. 2) Have methods which are not attached to specific class instances. That's a bit like static methods no ? I was incomplete. I should have said, Have *bundled* methods which are not attached to specific class instances. That is, I want to be able to have groups of static methods. Static classes are how this is currently accomplished, but if we can't have private constructors, there's no way to prevent someone from (pointlessly) instantiating a static class. Can methods be attached to packages in AS3.0? If so, that might help. 3) Be able to create classes that cannot be instantiated themselves but can be superclasses of concrete classes. Yes, I agree there. Removing the ability to create private constructors seems completely pointless. The rational behind it seems a bit like you don't need that, which is not a very strong point IMHO. Exactly! Replace the removed functionality with some other strategy, but don't just get rid of it and pretend nothing's wrong. -- Mike Keesey ___ 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] Abstract classes in AS3?
Where can I find the source code of HaXe written in HaXe itself. I think is one of the important milestones for a compiler, the possibility to compile the compiler with itselves :) ___ 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: Re: [Flashcoders] Abstract classes in AS3?
For compile time checks, just use a private constructor. As ActionScript allows one to access a private (not really private) super constructor in a subclass this works perfectly. At least this is what I do when I need an Abstract class in ActionScript. E.G. class com.tomsnyder.fasttmath2.studentclient.activities.tasks.AbstractTask { //private constructor to discourage instantiation private function AbstractTask() { //initialization code here } } Now there's no way to instantiate it, and the compiler will bitch about it if you try. I hope that helps. -Chris On 7/9/06, Weyert de Boer [EMAIL PROTECTED] wrote: I still think compile-time checks are the best to have... but this will serve very well. Thanks. ___ 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: Re: [Flashcoders] Abstract classes in AS3?
AS3 doesn't support private constructors. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Allen Sent: Tuesday, July 11, 2006 2:06 PM To: Flashcoders mailing list Subject: Re: Re: [Flashcoders] Abstract classes in AS3? For compile time checks, just use a private constructor. As ActionScript allows one to access a private (not really private) super constructor in a subclass this works perfectly. At least this is what I do when I need an Abstract class in ActionScript. E.G. class com.tomsnyder.fasttmath2.studentclient.activities.tasks.AbstractTask { //private constructor to discourage instantiation private function AbstractTask() { //initialization code here } } Now there's no way to instantiate it, and the compiler will bitch about it if you try. I hope that helps. -Chris On 7/9/06, Weyert de Boer [EMAIL PROTECTED] wrote: I still think compile-time checks are the best to have... but this will serve very well. Thanks. ___ 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: Re: [Flashcoders] Abstract classes in AS3?
Hello ;) In AS3 the private keyword it's removed !! ;) You can't use this keyword for your constructor :) EKA+ :) 2006/7/11, Chris Allen [EMAIL PROTECTED]: For compile time checks, just use a private constructor. As ActionScript allows one to access a private (not really private) super constructor in a subclass this works perfectly. At least this is what I do when I need an Abstract class in ActionScript. E.G. class com.tomsnyder.fasttmath2.studentclient.activities.tasks.AbstractTask { //private constructor to discourage instantiation private function AbstractTask() { //initialization code here } } Now there's no way to instantiate it, and the compiler will bitch about it if you try. I hope that helps. -Chris On 7/9/06, Weyert de Boer [EMAIL PROTECTED] wrote: I still think compile-time checks are the best to have... but this will serve very well. Thanks. ___ 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 ___ 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] Abstract classes in AS3?
Chris, from the latest AS3 Language Reference (http://livedocs.macromedia.com/flex/2/langref/index.html), in compile-time errors section : 1153 - A constructor can only be declared public I don't understand why Adobe do that ? If somebody have an idea, I'ld be buyer ? Chris Allen wrote: For compile time checks, just use a private constructor. As ActionScript allows one to access a private (not really private) super constructor in a subclass this works perfectly. At least this is what I do when I need an Abstract class in ActionScript. E.G. class com.tomsnyder.fasttmath2.studentclient.activities.tasks.AbstractTask { //private constructor to discourage instantiation private function AbstractTask() { //initialization code here } } Now there's no way to instantiate it, and the compiler will bitch about it if you try. I hope that helps. -Chris On 7/9/06, Weyert de Boer [EMAIL PROTECTED] wrote: I still think compile-time checks are the best to have... but this will serve very well. Thanks. ___ 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 ___ 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: Re: Re: [Flashcoders] Abstract classes in AS3?
Yep, Just realized you guys were talking AS3. My bad. -Chris On 7/11/06, eka [EMAIL PROTECTED] wrote: Hello ;) In AS3 the private keyword it's removed !! ;) You can't use this keyword for your constructor :) EKA+ :) 2006/7/11, Chris Allen [EMAIL PROTECTED]: For compile time checks, just use a private constructor. As ActionScript allows one to access a private (not really private) super constructor in a subclass this works perfectly. At least this is what I do when I need an Abstract class in ActionScript. E.G. class com.tomsnyder.fasttmath2.studentclient.activities.tasks.AbstractTask { //private constructor to discourage instantiation private function AbstractTask() { //initialization code here } } Now there's no way to instantiate it, and the compiler will bitch about it if you try. I hope that helps. -Chris On 7/9/06, Weyert de Boer [EMAIL PROTECTED] wrote: I still think compile-time checks are the best to have... but this will serve very well. Thanks. ___ 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 ___ 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] Abstract classes in AS3?
That does seem stupid and completely pointless. I use private constructors all the time. Is there an official rationale for this? -- T. Michael Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cédric Néhémie Sent: Tuesday, July 11, 2006 11:30 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? Chris, from the latest AS3 Language Reference (http://livedocs.macromedia.com/flex/2/langref/index.html), in compile-time errors section : 1153 - A constructor can only be declared public I don't understand why Adobe do that ? If somebody have an idea, I'ld be buyer ? ___ 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] Abstract classes in AS3?
private constructor is not ECMAScript ! to create a Singleton you can use a simple object inherit internal class, it's more clean :) links about this subject : http://blog.jasonnussbaum.com/?p=112 french discussion about this subject : http://groups.google.com/group/FCNG/browse_thread/thread/544f79b0b223b15a/e2b2527f81678da7?lnk=stq=constructeur+AS3rnum=1#e2b2527f81678da7 PS : sorry for my english ^_^ EKA+ :) 2006/7/11, Weyert de Boer [EMAIL PROTECTED]: Why is it removed? ___ 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] Abstract classes in AS3?
yes but i speak very badly in english !!! i can't explain you easily this change :( EKA+ :) 2006/7/11, Mike [EMAIL PROTECTED]: That does seem stupid and completely pointless. I use private constructors all the time. Is there an official rationale for this? -- T. Michael Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cédric Néhémie Sent: Tuesday, July 11, 2006 11:30 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? Chris, from the latest AS3 Language Reference (http://livedocs.macromedia.com/flex/2/langref/index.html), in compile-time errors section : 1153 - A constructor can only be declared public I don't understand why Adobe do that ? If somebody have an idea, I'ld be buyer ? ___ 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] Abstract classes in AS3?
Yeah, but what if you're doing an enumeration class, like so: class TransitionState { private function TransitionState() { } public static var NOT_PLAYED_IN:TransitionState = new TransitionState(); public static var PLAYING_IN:TransitionState = new TransitionState(); public static var PLAYED_IN:TransitionState = new TransitionState(); public static var PLAYING_OUT:TransitionState = new TransitionState(); public static var PLAYED_OUT:TransitionState = new TransitionState(); } I want to be able to assume that these are the only 5 TransitionState objects in existence! (Okay, somebody could extend the class and make more--are they adding final in AS3.0?) Or what about static method classes? Why should something like this be allowed?: var stupid:Math = new Math(); Or, to return to the original topic, what if you want to do a pseudo-abstract class? Saying it's not ECMAScript doesn't fully answer the question--what is ECMAScript's rationale for not allowing private constructors? -- T. Michael Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of eka Sent: Tuesday, July 11, 2006 11:45 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? private constructor is not ECMAScript ! to create a Singleton you can use a simple object inherit internal class, it's more clean :) links about this subject : http://blog.jasonnussbaum.com/?p=112 french discussion about this subject : http://groups.google.com/group/FCNG/browse_thread/thread/544f79b0b223b15 a/e2b2527f81678da7?lnk=stq=constructeur+AS3rnum=1#e2b2527f81678da7 PS : sorry for my english ^_^ EKA+ :) 2006/7/11, Weyert de Boer [EMAIL PROTECTED]: Why is it removed? ___ 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 ___ 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] Abstract classes in AS3?
I'm agree with Mike concerning the ECMAScript rationale : From the ECMA specifications (http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf) 7.5.3 Future Reserved Words The following words are used as keywords in proposed extensions and are therefore reserved to allow for the possibility of future adoption of those extensions. Syntax FutureReservedWord :: one of abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public There's no mention of any restrictions anywhere in the specifications, seems it's a choice of Adobe to restrict the usage of the private keyword for constructors. About instanciate the Math class, there is an error in Run Time errors section : 1075 - Math is not a constructor. You can not instantiate the Math class. They probably use the same type of restrictions as we discussed before. PS : sorry for my english too :( , french people and english don't really works fine together :) Mike wrote: Yeah, but what if you're doing an enumeration class, like so: class TransitionState { private function TransitionState() { } public static var NOT_PLAYED_IN:TransitionState = new TransitionState(); public static var PLAYING_IN:TransitionState = new TransitionState(); public static var PLAYED_IN:TransitionState = new TransitionState(); public static var PLAYING_OUT:TransitionState = new TransitionState(); public static var PLAYED_OUT:TransitionState = new TransitionState(); } I want to be able to assume that these are the only 5 TransitionState objects in existence! (Okay, somebody could extend the class and make more--are they adding final in AS3.0?) Or what about static method classes? Why should something like this be allowed?: var stupid:Math = new Math(); Or, to return to the original topic, what if you want to do a pseudo-abstract class? Saying it's not ECMAScript doesn't fully answer the question--what is ECMAScript's rationale for not allowing private constructors? -- T. Michael Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of eka Sent: Tuesday, July 11, 2006 11:45 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? private constructor is not ECMAScript ! to create a Singleton you can use a simple object inherit internal class, it's more clean :) links about this subject : http://blog.jasonnussbaum.com/?p=112 french discussion about this subject : http://groups.google.com/group/FCNG/browse_thread/thread/544f79b0b223b15 a/e2b2527f81678da7?lnk=stq=constructeur+AS3rnum=1#e2b2527f81678da7 PS : sorry for my english ^_^ EKA+ :) 2006/7/11, Weyert de Boer [EMAIL PROTECTED]: Why is it removed? ___ 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 ___ 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] Abstract classes in AS3?
Hello :) Yes for an enumeration you can use an internal class in your package and a Singleton namespace. private is good width a method and not a constructor. You can use throw error to limit your constructor or use internal keyworld, for me it's better ! EKA+ :) 2006/7/11, Cédric Néhémie [EMAIL PROTECTED]: I'm agree with Mike concerning the ECMAScript rationale : From the ECMA specifications (http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf ) 7.5.3 Future Reserved Words The following words are used as keywords in proposed extensions and are therefore reserved to allow for the possibility of future adoption of those extensions. Syntax FutureReservedWord :: one of abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public There's no mention of any restrictions anywhere in the specifications, seems it's a choice of Adobe to restrict the usage of the private keyword for constructors. About instanciate the Math class, there is an error in Run Time errors section : 1075 - Math is not a constructor. You can not instantiate the Math class. They probably use the same type of restrictions as we discussed before. PS : sorry for my english too :( , french people and english don't really works fine together :) Mike wrote: Yeah, but what if you're doing an enumeration class, like so: class TransitionState { private function TransitionState() { } public static var NOT_PLAYED_IN:TransitionState = new TransitionState(); public static var PLAYING_IN:TransitionState = new TransitionState(); public static var PLAYED_IN:TransitionState = new TransitionState(); public static var PLAYING_OUT:TransitionState = new TransitionState(); public static var PLAYED_OUT:TransitionState = new TransitionState(); } I want to be able to assume that these are the only 5 TransitionState objects in existence! (Okay, somebody could extend the class and make more--are they adding final in AS3.0?) Or what about static method classes? Why should something like this be allowed?: var stupid:Math = new Math(); Or, to return to the original topic, what if you want to do a pseudo-abstract class? Saying it's not ECMAScript doesn't fully answer the question--what is ECMAScript's rationale for not allowing private constructors? -- T. Michael Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of eka Sent: Tuesday, July 11, 2006 11:45 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? private constructor is not ECMAScript ! to create a Singleton you can use a simple object inherit internal class, it's more clean :) links about this subject : http://blog.jasonnussbaum.com/?p=112 french discussion about this subject : http://groups.google.com/group/FCNG/browse_thread/thread/544f79b0b223b15 a/e2b2527f81678da7?lnk=stq=constructeur+AS3rnum=1#e2b2527f81678da7 PS : sorry for my english ^_^ EKA+ :) 2006/7/11, Weyert de Boer [EMAIL PROTECTED]: Why is it removed? ___ 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 ___ 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 ___ 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] Abstract classes in AS3?
The official rationale can be found in Chapter 9 of the latest draft specification of ECMAScript 4th edition: quote Rationale: making a constructor always public reinforces the user model of classes, like functions, as constructors. While other languages allow constructors methods to be made inaccessible to keep outside code from creating instances, this use case was not deemed important enough to complicate the language design. It is a compatible change to allow explicit access control namespace attributes in a later edition. /quote The entire draft specification can be found online at the Mozilla website: http://developer.mozilla.org/es4/ If you are wondering why it would complicate the language design, my understanding is that the complication stems from ECMAScript's treatment of class objects and constructor methods. As one engineer described it to me, ECMAScript blurs the distinction between the two. Consequently, allowing access specifiers other than public on a constructor would require changes to the object model. This would have to be done carefully in order to preserve backward compatibility. If you feel that private constructors are an important language feature, please add a feature request on the Adobe feature request/bug report form: http://www.adobe.com/support/email/wishform Francis -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Mike Sent: Tuesday, July 11, 2006 11:45 AM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Abstract classes in AS3? That does seem stupid and completely pointless. I use private constructors all the time. Is there an official rationale for this? -- T. Michael Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cédric Néhémie Sent: Tuesday, July 11, 2006 11:30 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Abstract classes in AS3? Chris, from the latest AS3 Language Reference (http://livedocs.macromedia.com/flex/2/langref/index.html), in compile-time errors section : 1153 - A constructor can only be declared public I don't understand why Adobe do that ? If somebody have an idea, I'ld be buyer ? ___ 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] Abstract classes in AS3?
I don't really care whether they allow private constructors or not, as long as they provide some way of accomplishing the same thing. Specifically, I want to be able to: 1) Limit the number of instances of certain classes (singletons, enumerations). 2) Have methods which are not attached to specific class instances. 3) Be able to create classes that cannot be instantiated themselves but can be superclasses of concrete classes. #3 for example, is much better implemented with the abstract keyword than with private constructors, but AS3.0 doesn't have the abstract keyword, so now there is no way to elegantly accomplish this (i.e., in such a way that errors are caught at compile-time instead of runtime). So, yeah, make all constructors public if you must, but give us some other way to accomplish these things. -- T. Michael Keesey ___ 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] Abstract classes in AS3?
Hello :) Try this method : package { import flash.utils.getQualifiedClassName; import flash.errors.IllegalOperationError; class AbstractClass { public function AbstractClass () { var path:String = getQualifiedClassName(this) ; if( path == AbstractClass) { throw new IllegalOperationError(AbstractClass is abstract, you can't instanciate it directly.); } trace(in A constructor : + path); } } class MyClass extends AbstractClass { public function MyClass() { super() ; } } class MainClass { public function MainClass() { var i:MyClass = new MyClass() ; // ok var a:AbstractClass = new AbstractClass() ; // throw IllegalOperationError } } } EKA+ :) 2006/7/9, Weyert de Boer [EMAIL PROTECTED]: I am blind or is their no support for Abstract classes in AS3? ___ 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] Abstract classes in AS3?
Nice hack if you aks me. Thanks. Based on this hack I can be sure it's not supported. Sadly enough. Oh well, thanks for sharing the hack. Yours, Weyert Hello :) Try this method : package { import flash.utils.getQualifiedClassName; import flash.errors.IllegalOperationError; class AbstractClass { public function AbstractClass () { var path:String = getQualifiedClassName(this) ; if( path == AbstractClass) { throw new IllegalOperationError(AbstractClass is abstract, you can't instanciate it directly.); } trace(in A constructor : + path); } } class MyClass extends AbstractClass { public function MyClass() { super() ; } } class MainClass { public function MainClass() { var i:MyClass = new MyClass() ; // ok var a:AbstractClass = new AbstractClass() ; // throw IllegalOperationError } } } EKA+ :) 2006/7/9, Weyert de Boer [EMAIL PROTECTED]: I am blind or is their no support for Abstract classes in AS3? ___ 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 . ___ 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] Abstract classes in AS3?
Eka you are the fastest :) eka wrote: Hello :) Try this method : package { import flash.utils.getQualifiedClassName; import flash.errors.IllegalOperationError; class AbstractClass { public function AbstractClass () { var path:String = getQualifiedClassName(this) ; if( path == AbstractClass) { throw new IllegalOperationError(AbstractClass is abstract, you can't instanciate it directly.); } trace(in A constructor : + path); } } class MyClass extends AbstractClass { public function MyClass() { super() ; } } class MainClass { public function MainClass() { var i:MyClass = new MyClass() ; // ok var a:AbstractClass = new AbstractClass() ; // throw IllegalOperationError } } } EKA+ :) 2006/7/9, Weyert de Boer [EMAIL PROTECTED]: I am blind or is their no support for Abstract classes in AS3? ___ 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 ___ 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