Using Director > Writing Scripts with Lingo > Expressing literal values > Identifying cast members and casts

 

Identifying cast members and casts

Note: If you rearrange (and thus renumber) cast members while creating a movie, Director doesn't automatically update references to cast member numbers in Lingo scripts. Therefore, although some of the examples in this section illustrate how to reference cast members by number, the best practice is to always name cast members and refer to them by name in Lingo scripts.

Lingo refers to a cast member by using the term member followed by a cast member name or number in parentheses. (Cast member names are strings and follow the same syntax rules as other strings.) An alternative syntax is the term member, without parentheses, followed by the cast member name or number.

For example, the following all refer to cast member 50, which has the name Hammer:

member("Hammer")
member(50)
member "Hammer"
member 50 

If more than one cast contains a cast member with the same name, you must use a second parameter to specify the cast member's cast. When your movie uses more than one cast and you identify a cast member by its number, you must also specify the cast. Otherwise, the second parameter is optional.

To specify a cast without parentheses when using member, include the term of castLib followed by the cast's name or number. When the cast member's name is unique in the movie, the cast's name or number isn't required, but you can include it for clarity.

For example, the following statements refer to cast member 50, which is named Hammer, in castLib 4, which is named Tools:

member(50, 4)
member 50 of castLib 4

member("Hammer", 4)
member "Hammer" of castLib 4

member(50, "Tools")
member 50 of castLib "Tools"

member("Hammer", "Tools")
member "Hammer" of castLib "Tools"

If more than one cast member has the same name and you use the name in a script without specifying the cast or cast member number, Lingo uses the first (lowest numbered) cast member in the lowest numbered cast that has the specified name.