Re: [Flashcoders] AS3 properties woes
Thanks Steven In AS3 you can actually put code before a super() as you can in other methods in AS2. as i admitted, clearly need a some refactoringright now its just a prototype so i'm not too concerned On 1/24/07, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: I don't know about AS3 (and I can't imagine this is different from AS2) but you cannot put any code before super() in a constructor. super() must be the first line of code in a constructor. You should pass the labelClass value to the super constructor (watch your every move, super constructor). super(date); and in your parent function ClassName(lc:String) { labelClass = lc; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keith Salisbury Sent: Wednesday, January 24, 2007 6:32 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS3 properties woes Thanks guys, its was actually my fault, the example i gave was a little simpler than my real code, and i discovered i was calling setTitle from inside the super construtor, so obviously if i dont set my subclass variable before calling super() it wont use that variable. by changing the subclass constructor to this: public function DateMarker () { labelClass = date super(); } I have the desired functionalitythink i probably need to spend some time refactoring tho. The example i've given (aside from Petro's astute comment) should actually work as expected, not as i described!! Sorry for the distractions!!! ___ 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 -- [EMAIL PROTECTED] ___ 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] AS3 properties woes
Slightly confused I have a super class: package com.ktec.timeline { protected var labelClass:String = default; public class AbstractMarker { public function AbstractMarker () { labelClass = default; } public function showTitle (title:String):void { trace(span class=\ + labelClass + \ + title + /span) } } } and a subclass: package com.ktec.timeline { public class DateMarker extends AbstractMarker { public function DateMarker () { super(); labelClass = date } } } Then i use: var marker:DateMarker = new DateMarker() marker.showTitle(hello world) # span class=defaulthello world/span This isnt what i would expect? Can anyone enlighten me where i'm going wrong? thanks keith ___ 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] AS3 properties woes
Keith Salisbury Slightly confused I have a super class: package com.ktec.timeline { protected var labelClass:String = default; public class AbstractMarker { public function AbstractMarker () { labelClass = default; } public function showTitle (title:String):void { trace(span class=\ + labelClass + \ + title + /span) } } } and a subclass: package com.ktec.timeline { public class DateMarker extends AbstractMarker { public function DateMarker () { super(); labelClass = date } } } Then i use: var marker:DateMarker = new DateMarker() marker.showTitle(hello world) # span class=defaulthello world/span This isnt what i would expect? Can anyone enlighten me where i'm going wrong? thanks keith Hi Keith, Little question: what r u working under: Flash 9 Beta or Flex 2? I wonder your code even compiled. Move this line: protected var labelClass:String = default; inside your class definition. It's outside the scope of the class. I tried it out, worked fine for me. Cheers, Petro ___ 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] AS3 properties woes
Not an AS3 expert by any means, but my first thought is that the error is here: public class DateMarker extends AbstractMarker { public function DateMarker () { super(); labelClass = date } } I'm not sure, but the super() function looks out of place here. You're already invoking the AbstractMarker constructor by creating a subclass, so it should work by itself. I suspect that calling super() there has messed with your scope somehow. Feel free to shoot me down. Danny ___ 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] AS3 properties woes
Also not an AS3 expert, but I think Danny is wrong. The super function is necessary to call the parent constructor. I believe that the problem is related to what Petro said about labelClass being outside of the AbstractMarker class. I would also consider subclassing showTitle and adding a trace to see if the value is correct in the DateMarker version. If so, then someone the two labelClass variables aren't the same actual variable which would be weird :) Danny Kodicek wrote: Not an AS3 expert by any means, but my first thought is that the error is here: public class DateMarker extends AbstractMarker { public function DateMarker () { super(); labelClass = date } } I'm not sure, but the super() function looks out of place here. You're already invoking the AbstractMarker constructor by creating a subclass, so it should work by itself. I suspect that calling super() there has messed with your scope somehow. Feel free to shoot me down. Danny ___ 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] AS3 properties woes
Brandon Barkley Also not an AS3 expert, but I think Danny is wrong. The super function is necessary to call the parent constructor. Hi Brandon, I'm afraid u r wrong. Just try it out, the constructor IS being called once u extend the class. Cheers, Petro ___ 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] AS3 properties woes
Thanks guys, its was actually my fault, the example i gave was a little simpler than my real code, and i discovered i was calling setTitle from inside the super construtor, so obviously if i dont set my subclass variable before calling super() it wont use that variable. by changing the subclass constructor to this: public function DateMarker () { labelClass = date super(); } I have the desired functionalitythink i probably need to spend some time refactoring tho. The example i've given (aside from Petro's astute comment) should actually work as expected, not as i described!! Sorry for the distractions!!! thanks for the help tho keith ___ 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: SPAM-LOW: RE: [Flashcoders] AS3 properties woes
It happens because the compiler realizes you haven't called super() in your constructor and does it for you. Derek Vadneau - Original Message - From: Petro Bochan [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, January 24, 2007 9:20 AM Subject: SPAM-LOW: RE: [Flashcoders] AS3 properties woes Brandon Barkley Also not an AS3 expert, but I think Danny is wrong. The super function is necessary to call the parent constructor. Hi Brandon, I'm afraid u r wrong. Just try it out, the constructor IS being called once u extend the class. Cheers, Petro ___ 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: SPAM-LOW: RE: [Flashcoders] AS3 properties woes
If that's the case, that's a really stupid bit of functionality because you can't completely override a constructor. I was not aware that AS did it that way. Derek Vadneau wrote: It happens because the compiler realizes you haven't called super() in your constructor and does it for you. Derek Vadneau - Original Message - From: Petro Bochan [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, January 24, 2007 9:20 AM Subject: SPAM-LOW: RE: [Flashcoders] AS3 properties woes Brandon Barkley Also not an AS3 expert, but I think Danny is wrong. The super function is necessary to call the parent constructor. Hi Brandon, I'm afraid u r wrong. Just try it out, the constructor IS being called once u extend the class. Cheers, Petro ___ 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: SPAM-LOW: RE: [Flashcoders] AS3 properties woes
Programming ActionScript 3.0 Overview of ActionScript Programming Object-Oriented Programming in ActionScript Classes http://livedocs.macromedia.com/flex/2/docs/1842.html If the superclass constructor is not explicitly called, the compiler automatically inserts a call before the first statement in the constructor body. You can call super() anywhere in your constructor (before or after other code), but if you leave it out, super() is called for you. Derek Vadneau - Original Message - From: Brandon Barkley [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, January 24, 2007 10:20 AM Subject: Re: SPAM-LOW: RE: [Flashcoders] AS3 properties woes If that's the case, that's a really stupid bit of functionality because you can't completely override a constructor. I was not aware that AS did it that way. ___ 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] AS3 properties woes
I don't know about AS3 (and I can't imagine this is different from AS2) but you cannot put any code before super() in a constructor. super() must be the first line of code in a constructor. You should pass the labelClass value to the super constructor (watch your every move, super constructor). super(date); and in your parent function ClassName(lc:String) { labelClass = lc; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keith Salisbury Sent: Wednesday, January 24, 2007 6:32 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS3 properties woes Thanks guys, its was actually my fault, the example i gave was a little simpler than my real code, and i discovered i was calling setTitle from inside the super construtor, so obviously if i dont set my subclass variable before calling super() it wont use that variable. by changing the subclass constructor to this: public function DateMarker () { labelClass = date super(); } I have the desired functionalitythink i probably need to spend some time refactoring tho. The example i've given (aside from Petro's astute comment) should actually work as expected, not as i described!! Sorry for the distractions!!! ___ 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] AS3 properties woes
This behavior has changed in AS3, you can now call super() at any point in the constructor. -Original Message- From: Steven Sacks | BLITZ [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 24, 2007 7:53 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] AS3 properties woes I don't know about AS3 (and I can't imagine this is different from AS2) but you cannot put any code before super() in a constructor. super() must be the first line of code in a constructor. You should pass the labelClass value to the super constructor (watch your every move, super constructor). super(date); and in your parent function ClassName(lc:String) { labelClass = lc; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keith Salisbury Sent: Wednesday, January 24, 2007 6:32 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS3 properties woes Thanks guys, its was actually my fault, the example i gave was a little simpler than my real code, and i discovered i was calling setTitle from inside the super construtor, so obviously if i dont set my subclass variable before calling super() it wont use that variable. by changing the subclass constructor to this: public function DateMarker () { labelClass = date super(); } I have the desired functionalitythink i probably need to spend some time refactoring tho. The example i've given (aside from Petro's astute comment) should actually work as expected, not as i described!! Sorry for the distractions!!! ___ 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] AS3 properties woes
You can put code before super(). If you intend to use any super methods then you definitely need to call super() beforehand. But if you want to call a method of your sub class before super(), it does work. .. now I don't necessarily agree with doing that, but I guess it depends on what you need to accomplish. Derek Vadneau - Original Message - From: Steven Sacks | BLITZ [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, January 24, 2007 1:52 PM Subject: RE: [Flashcoders] AS3 properties woes I don't know about AS3 (and I can't imagine this is different from AS2) but you cannot put any code before super() in a constructor. super() must be the first line of code in a constructor. You should pass the labelClass value to the super constructor (watch your every move, super constructor). super(date); and in your parent function ClassName(lc:String) { labelClass = lc; } ___ 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