Example Of A Complete Behavior; Sending Messages To Behaviors Attached To Sprites - MACROMEDIA DIRECTOR MX-USING DIRECTOR MX Use Manual

Table of Contents

Advertisement

Example of a complete behavior

If the handlers described here were in one behavior, the script would look like this (the
command was added to the
puppetSound
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
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
command sends a message to a specified sprite. If none of the sprite's behaviors
handler in this example):
on mouseUp
in the Lingo Dictionary.
sendSprite
Behaviors 369

Advertisement

Table of Contents
loading

This manual is also suitable for:

Director mx

Table of Contents