Language Guide

CHAPTER 9
Script Objects
276 Inheritance and Delegation
tell JohnSon to changeVegetable()
Vegetable of John
--result: "Zucchini"
When you change the Vegetable property of script object JohnSon to
"Zucchini" with the changeVegetable command, the Vegetable
property of script object John also changes.
The previous example demonstrates an important point about inherited
properties: to refer to an inherited property from within a child script object,
you must use the reserved word my or of me to indicate that the value to
which you’re referring is a property of the current script object. (You can also
use the words of parent to indicate that the value is a property of the parent
script object.) If you don’t, AppleScript assumes the value is a local variable.
For example, if you refer to Vegetable instead of my Vegetable in the
changeVegetable handler in the previous example, the result is "Spinach".
script John
property Vegetable : "Spinach"
end script
script JohnSon
property parent : John
on changeVegetable()
set Vegetable to "Zucchini" (* creates a local variable called
Vegetable; doesn't change value of
the parent's Vegetable property *)
end changeVegetable
end script
tell JohnSon to changeVegetable()
Vegetable of John
--result: "Spinach"