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(){ > 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 in England and Wales. Visit our website at http://www.fpp.net/ _______________________________________________ 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