Behaviors
369
Example of a complete behavior
If the handlers described here were in one behavior, the script would look like this (the
puppetSound
command was added to the
on mouseUp
handler in this example):
property movement, noise
on getPropertyDescriptionList
set description = [:]
addProp description, #movement, [#default: 5, ¬
#format:#integer, #comment: "Set motion to ¬
the right:", #range: [#min:1, #max:10]]
addProp description, #noise, [#default:"", ¬
#format: #sound, #comment:"Sound cast ¬
member name"]
return description
end
on getBehaviorDescription
return "This changes sprite color and position"
end
on mouseUp me
set the foreColor of sprite the spriteNum of me ¬
to random(255)
puppetSound noise
end
on enterFrame me
if the locH of sprite the spriteNum of me > ¬
the stageRight then
set the locH of sprite the spriteNum ¬
of me = the stageLeft
else
set the locH of sprite the spriteNum of me to ¬
(the locH of sprite the spriteNum of me + ¬
movement)
end if
end
When this behavior is attached to a sprite, each time the playhead enters a frame, the sprite moves
to the right by the amount the user specifies. When the user clicks a sprite, its color changes and a
specified sound plays.
Sending messages to behaviors attached to sprites
Lingo can run handlers in behaviors attached to specific sprites by sending messages to the
behaviors attached to one sprite, all sprites, or several specific sprites.
Sending messages to a sprite
The
sendSprite
command sends a message to a specified sprite. If none of the sprite’s behaviors
has a handler that corresponds to the message, the message passes to the cast member script, the
frame script, and then the movie script. See
sendSprite
in the Lingo Dictionary.
Содержание 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...