To turn an internal script cast member into an external, linked script cast member:
Select the internal cast member and click the Script tab of the Property inspector.
1
Click Link Script As.
2
Enter a name for the script file in the Save As dialog box.
3
Click Save.
4
To reload a linked script after it is edited:
•
Use the
unloadMember
If a linked script is edited outside of Director, you can reload it by using the
command in the Message window. The following statement will cause the script
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:
correspond to classes.
Parent scripts
correspond to instances.
Child objects
Property variables
correspond to methods.
Handlers
correspond to the Super class or base class.
Ancestor scripts
command.
correspond to instance variables or member variables.
unloadMember
myScript
Writing Scripts with Lingo 417
to be
Need help?
Do you have a question about the DIRECTOR MX-USING DIRECTOR MX and is the answer not in the manual?