The way you had your code, the Child class will never receive the
killingFocus call. Add a Delegate within the Mother Class to put the
onKillFocus event into scope with Child...

import mx.utils.Delegate;

class Mother extends MovieClip {
    public var txt:TextField;
   
    public function Mother() {
        //this.onPress = killingFocus;
        this.txt.onKillFocus = Delegate.create(this, killingFocus);
    }
   
    public function killingFocus():Void {
        trace("testFunc in mother");
    }
   
}

HTH - Andrew Rost
-----Original Message-----
From: Johan Nyberg [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 21, 2007 3:10 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Problem extending inherited function

Hi, I have a problem extending an inherited function. I put all the 
files described here in a zip if you want to test it yourselves: 
http://www.webguidepartner.com/~johan/super-problem.zip

I have this mother-class:


class Mother extends MovieClip {
    public var txt:TextField;
   
    public function Mother() {
        this.onPress = killingFocus;
        //this.txt.onKillFocus = killingFocus;
    }
   
    public function killingFocus():Void {
        trace("testFunc in mother");
    }
   
}


...and this child-class that inherits from Mother:


class Child extends Mother {
    public function Child() {
        super();
    }
   
    public function killingFocus():Void {
        super.killingFocus();
        trace("testFunc in child");
    }
}
 

Now, I have a test.fla that contains a movie clip that is linked to 
Child. Everything works as expected, both lines of trace running on the 
onPress.

But now: comment out the onPress-event in the constructor in Mother, and 
uncomment the second line: this.txt.onKillFocus = killingFocus;

Now, there is a text field inside the movie clip. When this text field 
loses focus, you wold expect the code to run the same way, but no. The 
killingFocus-function in Mother is overwritten and only the trace in 
Child runs.

I have some clue that the problem must have something to do with that it 
is the text field that triggers the event, and not the movie clip. But 
you would expect the super.killingFocus(); to work anyway, regardless of 
what calls the function?!


Regards,

/Johan


-- 
Johan Nyberg

Web Guide Partner
Sergels Torg 12, 8 tr
111 57 Stockholm 
070 - 407 83 00

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to