[Flashcoders] How do I remove methods of superclass in AS2?
Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] How do I remove methods of superclass in AS2?
How about: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){trace(NoAnswerBut created);} public function onPress(){}//no actions here public function onRelease(){}//no actions here } Another option is to override the actions. Otherwise if you want to get rid of the mouse events you could do this: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); } } However, I recommend this one: // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); onPress = _onPress onRelease = _onRelease } public function _onPress(){ //actions here } public function _onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); // not sure if you even need to do this: // as long as you don't call super(); onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); } } Hope this helps... Karim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: 01 May 2008 12:21 To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date: 30/04/2008 18:10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] How do I remove methods of superclass in AS2?
You can with override -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Alistair Colling Verzonden: donderdag 1 mei 2008 13:21 Aan: Flash Coders List Onderwerp: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG. Version: 8.0.100 / Virus Database: 269.23.7/1408 - Release Date: 4/30/2008 6:10 PM ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How do I remove methods of superclass in AS2?
Thanks for your responses guys, I have removed onPress/onRelease events as you suggested onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); but now my nested mc will not fire any mouse events, I am guessing that these mouse events have been removed for any nested clips in that mc too. I've un-nested my movie clip to solve the problem and it all works fine. Your help is appreciated :) Ali On 1 May 2008, at 12:44, Karim Beyrouti wrote: How about: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){trace(NoAnswerBut created);} public function onPress(){}//no actions here public function onRelease(){}//no actions here } Another option is to override the actions. Otherwise if you want to get rid of the mouse events you could do this: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); } } However, I recommend this one: // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); onPress = _onPress onRelease = _onRelease } public function _onPress(){ //actions here } public function _onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); // not sure if you even need to do this: // as long as you don't call super(); onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); } } Hope this helps... Karim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: 01 May 2008 12:21 To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date: 30/04/2008 18:10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Alistair Colling Interactive Developer FPP Brand Communications (Newcastle upon Tyne) The Courtyard Dinsdale Place Sandyford Newcastle upon Tyne NE2 1BD Telephone: +44 (0)191 261 6662 Fax: +44 (0)191 233 2511 This transmission is confidential and intended solely for the person or organisation to whom it is addressed. It may contain privileged and confidential information. If you are not the intended recipient, you should not copy, distribute or take any action in reliance on it. If you have received this transmission in error, please notify the sender at the e-mail address above. FPP Design Limited. Reg. Office: The Courtyard, Dinsdale Place, Sandyford, Newcastle upon Tyne NE2 1BD. Registered Number 3775564. Registered
Re: [Flashcoders] How do I remove methods of superclass in AS2?
Thanks for your responses guys, I have removed onPress/onRelease events as you suggested onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); but now my nested mc will not fire any mouse events, I am guessing that these mouse events have been removed for any nested clips in that mc too. I've un-nested my movie clip to solve the problem and it all works fine. Your help is appreciated :) Ali On 1 May 2008, at 12:46, Cor wrote: You can with override -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Alistair Colling Verzonden: donderdag 1 mei 2008 13:21 Aan: Flash Coders List Onderwerp: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG. Version: 8.0.100 / Virus Database: 269.23.7/1408 - Release Date: 4/30/2008 6:10 PM ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] How do I remove methods of superclass in AS2?
That is why I recommend this approach: class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); addMouseEvents(); } public function _onPress(){ //actions here } public function _onRelease(){ //actions here } public function removeMouseEvents(){ onPress = undefined onRelease = undefined delete(onPress) delete(onRelease) } public function addMouseEvents(){ onPress = _onPress onRelease = _onRelease } } Which you can override in your class: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ addMouseEvents() } public function _onPress(){ //other actions here } public function _onRelease(){ // other actions here } } So that way when you removeMouseEvents(), you still keep the actions and can re-assign them at the onPress/onRelease handlers... I would also recomend you use the Delegate class for this... to do something like ... onRelease = Delegate.create( this, _onRelease ) keeps the calls in scope if you are assigning events to sub movieclip. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: 01 May 2008 14:56 To: Flash Coders List Subject: Re: [Flashcoders] How do I remove methods of superclass in AS2? Thanks for your responses guys, I have removed onPress/onRelease events as you suggested onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); but now my nested mc will not fire any mouse events, I am guessing that these mouse events have been removed for any nested clips in that mc too. I've un-nested my movie clip to solve the problem and it all works fine. Your help is appreciated :) Ali On 1 May 2008, at 12:44, Karim Beyrouti wrote: How about: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){trace(NoAnswerBut created);} public function onPress(){}//no actions here public function onRelease(){}//no actions here } Another option is to override the actions. Otherwise if you want to get rid of the mouse events you could do this: class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); } } However, I recommend this one: // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); onPress = _onPress onRelease = _onRelease } public function _onPress(){ //actions here } public function _onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); // not sure if you even need to do this: // as long as you don't call super(); onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); } } Hope this helps... Karim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: 01 May 2008 12:21 To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut
RE: [Flashcoders] How do I remove methods of superclass in AS2?
Override the functions instead with the override keyword. Something like this: override public function onPress(e:Event):void { } Jason Merrill Bank of America Global Technology Operations LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: Thursday, May 01, 2008 7:21 AM To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] How do I remove methods of superclass in AS2?
Sadly - override is AS3 only ... not AS2... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: 01 May 2008 15:26 To: Flash Coders List Subject: RE: [Flashcoders] How do I remove methods of superclass in AS2? Override the functions instead with the override keyword. Something like this: override public function onPress(e:Event):void { } Jason Merrill Bank of America Global Technology Operations LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: Thursday, May 01, 2008 7:21 AM To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date: 30/04/2008 18:10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] How do I remove methods of superclass in AS2?
Yeah, I just noticed the poster said AS2, not 3... disregard. Jason Merrill Bank of America Global Technology Operations LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Karim Beyrouti Sent: Thursday, May 01, 2008 10:37 AM To: 'Flash Coders List' Subject: RE: [Flashcoders] How do I remove methods of superclass in AS2? Sadly - override is AS3 only ... not AS2... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: 01 May 2008 15:26 To: Flash Coders List Subject: RE: [Flashcoders] How do I remove methods of superclass in AS2? Override the functions instead with the override keyword. Something like this: override public function onPress(e:Event):void { } Jason Merrill Bank of America Global Technology Operations LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: Thursday, May 01, 2008 7:21 AM To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date: 30/04/2008 18:10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How do I remove methods of superclass in AS2?
Doesn't make any difference - the same thing works in AS2, you just don't use the 'override' keyword. Override has been added to AS3 to perform additional compile checking (and possibly to allow optimisation), not to add new functionality. And, from whatever the other bit of the thread was: onPress = undefined ; onRelease = undefined ; delete(onPress); delete(onRelease); You don't need both these operations - either setting to undefined (null is better) or calling delete will do the job, no need for both. Ian On Thu, May 1, 2008 at 4:02 PM, Merrill, Jason [EMAIL PROTECTED] wrote: Yeah, I just noticed the poster said AS2, not 3... disregard. Jason Merrill Bank of America Global Technology Operations LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Karim Beyrouti Sent: Thursday, May 01, 2008 10:37 AM To: 'Flash Coders List' Subject: RE: [Flashcoders] How do I remove methods of superclass in AS2? Sadly - override is AS3 only ... not AS2... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: 01 May 2008 15:26 To: Flash Coders List Subject: RE: [Flashcoders] How do I remove methods of superclass in AS2? Override the functions instead with the override keyword. Something like this: override public function onPress(e:Event):void { } Jason Merrill Bank of America Global Technology Operations LLD eTools Multimedia Join the Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alistair Colling Sent: Thursday, May 01, 2008 7:21 AM To: Flash Coders List Subject: [Flashcoders] How do I remove methods of superclass in AS2? Hiya, thanks for checking this. I have a custom class that I am using as kind of button. The thing is I now want to remove the onPress and onRelease methods as there is a nested movieclip I want to attach these events to. What I would like to know is can I remove or nullify the methods of a superclass from the subclass? Any help very much appreciated, an outline of my code is below. Thanks :) Ali // superclass class Classes.AnswerBut extends MovieClip{ function AnswerBut(){ trace(AnswerBut created); } public function onPress(){ //actions here } public function onRelease(){ //actions here } } //subclass class Classes.NoAnswerBut extends Classes.AnswerBut{ function NoAnswerBut(){ trace(NoAnswerBut created); } // I want to remove the onPress / onRelease events in the class definition here } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date: 30/04/2008 18:10 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders