Az Expattech az ünnepek alatt (dec.24-jan.1.) zárva tart. Nyitás: 2024.január 2

ExpatTech Techblog

Peter Todd 2010.11.03. 12:09

Flash Cookbook - Tricks - Reach property of subclass from baseclass, crosslinking

If you extend a base class and still want to reach properties of the subclass, use the hasOwnProperty method.

BASE CLASS:

if(this.hasOwnProperty(PROPERTY_NAME_STRING)) this[PROPERTY_NAME_STRING] do something;

This wouldn't work:

BASE CLASS:

this.FUNCTION_OF_SUBCLASS();

This is useful, if you have different subclasses of the same baseclass, but want to assign unique variables or functions to each subclass.

Note: it's better to make the specific property public.

Tags: