Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-26-2009, 11:49 AM   #1
lope
Registered User
extending a class 2 times :D

i have class A, then class B which entends class A, then class C which entends class B.
now in class A there are couple of empty methods currently defined as protected.
in class B these methods are also empty //i dont know how to make this exactly, they should obvioulsy be here as well because... ->
then in class C i want to override these methods and actually do something in them.

so how do i stretch these empty methods from class A to class C?
don tell me this has to go like this?
Code:
class A:
protected function rollOverHandler(e:MouseEvent):void {}
class B:
override protected function rollOverHandler(e:MouseEvent):void {
     super.rollOverHandler();//do i need this because nothing is happening above?
}
class C:
override protected function rollOverHandler(e:MouseEvent):void {
     do something here...
}
lope is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-26-2009, 02:40 PM   #2
Krilnon
≈ ≠ =
 
Krilnon's Avatar
Location Rochester, NY

Posts 7,183
You can just override them in C and ignore them in B, and you don't need to call the superclass' version if it's empty (or doesn't do anything that you want it to do in C).

ActionScript Code:
// class A:
protected function rollOverHandler(e:MouseEvent):void {}

// class C:
override protected function rollOverHandler(e:MouseEvent):void {
     //do something here...
}
Krilnon is offline   Reply With Quote
Old 11-27-2009, 05:43 AM   #3
lope
Registered User
what if you are extending a class that already overrides some methods and you want to override that methods in the extending class?
so class B extends class A, method from class B:
Code:
override protected function rollOverHandler(e:MouseEvent):void {
then in class C:
Code:
override protected function rollOverHandler(e:MouseEvent):void 
//some code
//maybe also call super.rollOverHandler() before or after some code{
is this fine?

also, in class B i had a call to super (meaning to class A)
now if i want to call super in class A from class C that wont work ?

and why does super in subclass traces as object subclass?
i was expecting it to trace object superclass...

Last edited by lope; 11-27-2009 at 07:11 AM..
lope is offline   Reply With Quote
Old 11-27-2009, 12:32 PM   #4
Eric Drutel
Registered User
It is not possible to call from C directly the rollOverHandler() method from class A (super.super.rollOverHandler won't work).
A call super.rollOverHandler() in C would call rollOverHandler from B. If in B super.rollOverHandler() is called only then the execution will step in rollOverHandler() from A.
Eric Drutel is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:22 AM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com