This is a simple scope issue. The problem is caused exactly by that
what you talked about. When assigning killingFocus to the textfield's
event, use some kind of delegation (e.g. mx.util.Delegate):

txt.onKillFocus = mx.utils.Delegate.create(this, killingFocus);

(off: actually, "this" is not required inside AS2 classes)

  Attila


JN> Hi, I have a problem extending an inherited function. I put all the
JN> files described here in a zip if you want to test it yourselves: 
JN> http://www.webguidepartner.com/~johan/super-problem.zip
JN> 
JN> I have this mother-class:
JN> 
JN> 
JN> class Mother extends MovieClip {
JN>     public var txt:TextField;
JN>    
JN>     public function Mother() {
JN>         this.onPress = killingFocus;
JN>         //this.txt.onKillFocus = killingFocus;
JN>     }
JN>    
JN>     public function killingFocus():Void {
JN>         trace("testFunc in mother");
JN>     }
JN>    
JN> }
JN> 
JN> 
JN> ...and this child-class that inherits from Mother:
JN> 
JN> 
JN> class Child extends Mother {
JN>     public function Child() {
JN>         super();
JN>     }
JN>    
JN>     public function killingFocus():Void {
JN>         super.killingFocus();
JN>         trace("testFunc in child");
JN>     }
JN> }
JN>  
JN> 
JN> Now, I have a test.fla that contains a movie clip that is linked to 
JN> Child. Everything works as expected, both lines of trace running on the 
JN> onPress.
JN> 
JN> But now: comment out the onPress-event in the constructor in Mother, and 
JN> uncomment the second line: this.txt.onKillFocus = killingFocus;
JN> 
JN> Now, there is a text field inside the movie clip. When this text field 
JN> loses focus, you wold expect the code to run the same way, but no. The 
JN> killingFocus-function in Mother is overwritten and only the trace in 
JN> Child runs.
JN> 
JN> I have some clue that the problem must have something to do with that it 
JN> is the text field that triggers the event, and not the movie clip. But 
JN> you would expect the super.killingFocus(); to work anyway, regardless of 
JN> what calls the function?!


_______________________________________________
[email protected]
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