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

Reply via email to