Writing Scripts with Lingo
393
Dot syntax
Dot syntax is a concise form of Lingo that makes longer scripts easier to read and comprehend for
users who have at least a basic understanding of the language. By understanding and using dot
syntax, you can make your scripts shorter and easier to read and debug. An understanding of
dot syntax makes it easier to learn other programming languages, since many of them use dot
syntax exclusively.
If you are just beginning to learn Lingo, you will probably want to start with verbose syntax and
then begin using dot syntax as your understanding of Lingo improves. You can use verbose
syntax and dot syntax in combination. You may want to do this as you begin the process of
learning dot syntax.
Because most users will want to use dot syntax after they achieve a basic understanding of Lingo,
most of the Lingo examples in this book are written with dot syntax. However, this chapter will
provide extensive examples of both syntaxes.
Almost any Lingo statement can be written with either verbose syntax or dot syntax. The
following example demonstrates how the two types of syntax relate to each other.
This statement sets the forecolor of sprite 12 to 155 using verbose syntax:
set the forecolor of sprite 12 to 155
The following statement does the same thing by using dot syntax. It also omits the
set
command, which is optional:
sprite(12).forecolor = 155
You can use dot syntax to express the properties or functions related to an object or to specify
a chunk of text within a text object. A dot syntax expression begins with the name of the
object, followed by a period (dot), and then the property, function, or text chunk that you
want to specify.
For example, the
loc of sprite
property indicates a sprite’s horizontal and vertical position on
the Stage. The expression
sprite(15).loc
refers to the
loc of sprite
property of sprite 15.
As another example, the
number
cast member property specifies a cast member’s number. The
expression
member("Hot Button").number
refers to the cast member number of the Hot Button
cast member.
Expressing a function related to an object follows the same pattern. For example, the
pointInHyperLink
text sprite function reports whether a specific point is within a hyperlink in a
text sprite. In addition to the syntax demonstrated in the Lingo Dictionary, you can use the dot
syntax
textSpriteObject
.pointInHyperlink()
to express this function.
The following
put
statement will evaluate the specified expression and return
TRUE
or
FALSE
depending on whether the pointer is located over a hyperlink in the text sprite in channel 3:
put sprite(2).pointInHyperlink(mouseLoc)
This is how the same statement is written with verbose syntax:
put pointInHyperlink(sprite 2, the mouseLoc)
To identify chunks of text, include terms after the dot to refer to more specific items within text.
For example, the expression
member("News Items").paragraph(1)
refers to the first paragraph
of the text cast member News Items. The expression
member("News
Items").paragraph(1).line(1)
refers to the first line in the first paragraph. These text chunk
expressions are available only with dot syntax.
Содержание DIRECTOR MX-USING 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...