Lingo Inheritance

From Director Online Wiki
Jump to: navigation, search

Inheritance is a Object Oriented Programming feature. To use it in Lingo, do the following (note that this is different from the Director Documentation - but it is how inheritance actually works in Lingo. In a script that should inherit all properties and methods from an ancestor, create a property "ancestor".

like this:

 property ancestor

then in the script define the ancestor:

 ancestor = script("parent").rawNew()


rawNew creates the script without calling new. If you want to call new, do it this way:

 callAncestor(#new, me, anArgument)

Now you can access all properties and methods of the ancestors by using "me". Then Director will search through the Ancestor Chain and will find the latest definition of the property/method. Only if you use this way with rawNew, then using "me" in the ancestors will work properly (and use possible methods from the inheritant).