
Using inheritance in behaviors
289
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
is a property in the
property
statement at the beginning of the
behavior’s Score script.
For example, the statement
property ancestor
declares that
ancestor
is a property.
•
Include a statement that specifies which script is the ancestor. Put the statement in an
on
beginSprite
handler in the behavior.
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.
Содержание DIRECTOR MX 2004-USING DIRECTOR
Страница 1: ...DIRECTOR MX 2004 Using Director...
Страница 16: ...16 Chapter 1 Introduction...
Страница 82: ...82 Chapter 3 Sprites...
Страница 98: ...98 Chapter 4 Animation...
Страница 134: ...134 Chapter 5 Bitmaps...
Страница 242: ...242 Chapter 10 Sound and Synchronization...
Страница 274: ...274 Chapter 11 Using Digital Video...
Страница 290: ...290 Chapter 12 Behaviors...
Страница 302: ...302 Chapter 13 Navigation and User Interaction...
Страница 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Страница 392: ...392 Chapter 16 Working with Models and Model Resources...
Страница 418: ...418 Chapter 18 Movies in a Window...
Страница 446: ...446 Chapter 22 Managing and Testing Director Projects...