Alex meant to say "If a method is overridden, you can NOT skip around
the override like you can in some other languages." And you can't
directly, with super.super. But you can, indirectly.
 
The way the framework codes around the lack of super.super is to use the
following pattern:
 
class A
{
    function f()
    {
        doSomething();
    }
}
 
class B extends A
{
    // This will hide A's f()
    override function f()
    {
        doSomethingElse();
    }
 
    // But this makes A's f() available as B's $f
    final function $f()
    {
        super.f();
    }
}
 
class C extends B
{
    override function f()
    {
        $f(); // call A's f() -- which is effectively super.super.f()
    }
}
 
Using $ in the name is just a convention which indicates that you're
getting the original, un-overridden function. We also make it final to
guarantee that it remains un-overridden.
 
- Gordon

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Wednesday, May 30, 2007 2:10 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Is there any way to call
super.super.method in AS3?



Sorry, but I think you're wrong or misunderstood.  If a method is
overridden, you can skip around the override like you can in some other
languages

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of justinbuser
Sent: Wednesday, May 30, 2007 10:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Is there any way to call super.super.method in
AS3?

        

--- In flexcoders@yahoogroups.com, "wpding" <[EMAIL PROTECTED]> wrote:
>
> I want to override a method of a super class. and I can use
> super.method to invoke the corresponding method of the super class.
> 
> But how i can call a method of the super super class.
> for example.
> Class A{
> protected function myMethod(){}
> }
> Class B extends A{
> override protected function myMethod(){}
> }
> 
> Class C extends B{
> override protected function myMethod(){}
> }
> 
> Is it possible to call A.myMethod in the function C.MyMethod?
> 
> Thanks
>
Yes, exactly how you wrote it.  However in order to have the top level
function actually run before adding methods etc... with level 2 you need
to call super.myMethod(); from B or not override it at all in B to be
able to access it's functionality! from C.  In other words, if you
override a function and then try to override it again in a class
extending the one with the original override and don't call the super
version in the intermediate class then you end up with an empty function
at the end.

JjB

-#As always I could be completely wrong, but it's not likely#-

 

Reply via email to