all groups > flash actionscript > november 2005 >
You're in the

flash actionscript

group:

superclass access over larger-than-2 hierarchy



superclass access over larger-than-2 hierarchy andres_z
11/30/2005 9:22:23 PM
flash actionscript: Basically, consider the following:

class A: defines some method m;
class B extends A: overrides m;
class C extends B: overrides m and defines some other method n.

Now, C::n wants to access A::m. How to do it? I've tried coercion: A(this).m()
which will invoke C::m and I have no other ideas. Any ideas are welcome.

Re: superclass access over larger-than-2 hierarchy LuigiL
11/30/2005 10:55:32 PM
Two options:
If A.m is a static method you can use A.m in method n in C. But then you would
not be able to manipulate any instance props in A.
Or use composition to create an instance of A in C and use the instance to
call the method.
Re: superclass access over larger-than-2 hierarchy andres_z
12/1/2005 12:00:00 AM
LuigiL: A::m is not static; Composition is not an option as well because
objects contain some critical references and the functionality is layered
throught the hierarchy such that I'm (un)able to invoke a version of superclass
as necessary.
I have a workaround though (rename A::m to smth else), which is a hack but it
works.

Srayer_CA: since C has inherits B & A, it's also A and thus has access to its
properties and methods. And as such, I SHOULD be able to invoke any version
from any class of a method along the inheriance tree. Consider C++ where I can
tell (Type::method() if I remember the syntax) the compiler which version of a
method I'm invoking at a certain point. But it seems not the case for AS.
Neither does this work in AS3 which is provided with FB2.0 :(


Re: superclass access over larger-than-2 hierarchy LuigiL
12/1/2005 12:00:00 AM
Re: superclass access over larger-than-2 hierarchy Srayer_CA
12/1/2005 1:00:43 AM
AddThis Social Bookmark Button