Writing Scripts with Lingo
417
To turn an internal script cast member into an external, linked script cast member:
1
Select the internal cast member and click the Script tab of the Property inspector.
2
Click Link Script As.
3
Enter a name for the script file in the Save As dialog box.
4
Click Save.
To reload a linked script after it is edited:
•
Use the
unloadMember
command.
If a linked script is edited outside of Director, you can reload it by using the
unloadMember
command in the Message window. The following statement will cause the script
myScript
to be
unloaded and then reloaded:
unloadMember member "myScript"
Using parent scripts and child objects
Parent scripts provide the advantages of object-oriented programming within Director. These
advantages include the ability to write less code and use simpler logic to accomplish tasks in
Lingo. You can use parent scripts to generate script objects that behave and respond similarly yet
can still operate independently of each other.
Lingo can create multiple copies (or instances) of a parent script. Each instance of a parent script
is called a child object. You can create child objects on demand as the movie plays. Director
doesn’t limit the number of child objects that can be created from the same parent script. You can
create as many child objects as the computer’s memory can support.
Director can create multiple child objects from the same parent script, just as Director can create
multiple instances of a behavior for different sprites. You can think of a parent script as a template
and of child objects as implementations of the parent template.
This section describes the basics of how to write parent scripts, and create and use child objects,
and it provides script examples. It doesn’t teach fundamental object-oriented programming
concepts; however, to use parent scripts and child objects successfully, you must understand
object-oriented programming principles. For an introduction to the basics of object-oriented
programming, see one of the many third-party books on that subject.
Similarity with other object-oriented languages
If you are familiar with an object-oriented programming language such as Java or C++, you may
already understand the concepts that underlie parent scripting but know them by different names.
Terms that Director uses to describe parent scripts and child objects correspond to the following
common object-oriented programming terms:
Parent scripts
correspond to classes.
Child objects
correspond to instances.
Property variables
correspond to instance variables or member variables.
Handlers
correspond to methods.
Ancestor scripts
correspond to the Super class or base class.
Содержание Director MX
Страница 1: ...Using Director MX Macromedia Director MX ...
Страница 12: ...Contents 12 ...
Страница 156: ...Chapter 4 156 ...
Страница 202: ...Chapter 6 202 ...
Страница 244: ...Chapter 7 244 ...
Страница 292: ...Chapter 10 292 ...
Страница 330: ...Chapter 12 330 ...
Страница 356: ...Chapter 13 356 ...
Страница 372: ...Chapter 14 372 ...
Страница 442: ...Chapter 16 442 ...
Страница 472: ...Chapter 18 472 ...
Страница 520: ...Chapter 19 520 ...
Страница 536: ...Chapter 20 536 ...
Страница 562: ...Chapter 23 562 ...
Страница 566: ...Chapter 24 566 ...
Страница 602: ...Chapter 27 602 ...