Behaviors versus Other Script Types
Now that you understand a bit about objects, let’s revisit Behaviors. Ironically, Behaviors are most useful to users at opposite ends of the spectrum. Beginners can use prewritten Behaviors without understanding their inner workings, and experts can create their own powerful Behaviors. I’ll assume you are somewhere in between and that most of the Behaviors in the Behavior Library are too simple for your needs, yet you have no idea how to construct your own Behavior or even when you should try.
What Is a Behavior Script?
When I first used Behaviors I thought of them as parent (that is, object-oriented) scripts tied to a sprite or frame. Now that I’ve used them for a while, I think of them as instantiated score scripts. Table 12-1 shows some important differences among these three types of scripts. For the purposes of this table, the term score script refers to simple Director 5 style score scripts (In D6, a score script is a Behavior is a score script.)
Table 12-1. Behaviors, Score Scripts, and Parent Scripts
Type |
Instantiated? |
Attached to |
Script Type |
User-configurable Properties? |
Easy to Write? |
Easy to Use? |
---|---|---|---|---|---|---|
[a] | ||||||
[b] | ||||||
Score Script |
Yes[a] |
Sprite or Frame |
#score |
No |
Easiest |
Medium |
Behavior |
Yes[a] |
Sprite or Frame |
#score |
Usually |
Hardest |
Easiest |
Parent Script |
Manually[b] |
Nothing |
#parent |
No |
Medium |
Hardest |
[a] 1All score scripts are instantiated automatically by Director 6 when the sprite or frame to which they are attached is encountered, ... |
Get Lingo in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.