Using inheritance in behaviors
Behaviors can have ancestor scripts in the same way that parent scripts do. (Ancestor scripts are
additional scripts whose handlers and properties a parent script can call on and use.)
•
The ancestor's handlers and properties are available to the behavior.
•
If a behavior has the same handler or property as an ancestor script, then the script uses the
property or handler in the behavior instead of the one in the ancestor.
For more information about the concept of ancestors and inheritance, see the Scripting Reference
topics in the Director Help Panel.
To make a script an ancestor, do one of the following:
•
Declare that
ancestor
behavior's Score script.
For example, the statement
•
Include a statement that specifies which script is the ancestor. Put the statement in an
beginSprite
For example, this handler makes the script Common Behavior an ancestor of the behavior
when Director first enters the sprite:
--Lingo syntax
on beginSprite
sprite(me.spriteNum).ancestor = script("Common Behavior").new()
end
This handler will let the behavior also use the handler in the script Common Behavior.
is a property in the
property ancestor
handler in the behavior.
statement at the beginning of the
property
declares that
ancestor
Using inheritance in behaviors
is a property.
on
289
Need help?
Do you have a question about the DIRECTOR MX 2004-USING DIRECTOR and is the answer not in the manual?
Questions and answers