von dp am 24.April 97 um 22:19:39:
A "send" command was partially implemented in D400... I don't recall whether it
was used internally by Lingo itself or whether it was an experimental piece of
Lingo that did not pass through full QA. Whatever, it wasn't included in the D4
feature set, although someone did apparently ResEdit in later and saw that it
was a reserved keyword, publicizing it as some great hidden secret.
What most do, though, if you need to fire a message off to a particular script,
is to use the normal parent/child syntax discussed in the D404 ReadMe file. A
script is an object, just like an instance of a script is an object. Instead of
using greymarket Lingo you can just:
>> mouseDown (script (the frameScript))
or whatever.
Just sending a message to an arbitrary script is pretty rare... slightly less
rare is using a private script to store persistent private variables, as in the
counter frame script:
>> property counter
>>
>> on exitFrame
>> set me to script (the frameScript)
>> if voidP(the counter of me) then set the counter of me to 0
>> set the counter of me to 1 + the counter of me
>> if the counter of me < 100 then go the frame
>> end
or, rephrased:
>> property counter
>>
>> on exitFrame
>> set me to script (the frameScript)
>> Increment me
>> end
>>
>> on Increment me
>> if voidP(counter) then set counter to 0
>> set counter to counter + 1
>> if counter < 100 then go the frame
>> end
(The "of me" line is not necessary if you already have the object reference in
the first argument passed to a handler... if calling to arbitrary object
references, then you'd have to use "the property of whichObject" syntax, as in
the first example.)
In Director 6 this latter approach is used more extensively... behaviors have
shared methods and private properties. Here's the corresponding behavior for a
more general "stay here for X frames" behavior:
>> property spriteNum, counter, totalReps
>>
>> on beginSprite me
>> set counter to 0
>> end
>>
>> on exitFrame me
>> set counter to counter + 1
>> if counter < totalReps then go the frame
>> end
>>
>> on getPropertyDescriptionList me
>> set theProps to [:]
>> set comment to "How many repetitions?"
>> set format to #integer
>> set default to 100
>> set repsProps to [#comment: comment, #format: format, #default: default]
>> addProp theProps, #totalReps, repsProps
>> return theProps
>> end
The basic Lingo for managing a persistent private variable is simpler than
before. The last "getPropertyDescriptionList" handler is necessary for creating
an automatic dialog box where the designer can dial in how many times they wish
to stay on the frame.
And to bring this full circle, D6 can send a message to all current sprites
through the "sendAllSprites" command. The following sorta silly script lets the
designer specify a message to send to all other sprites after every X frames,
and the message and number of frames can vary for each sprite that has this
behavior:
>> property spriteNum, counter, reps, secretMessage
>>
>> on beginSprite me
>> set counter to 0
>> end
>>
>> on exitFrame me
>> set counter to counter + 1
>> if (counter mod reps) = 0 then sendAllSprites(symbol(secretMessage))
>> end
>>
>> on getPropertyDescriptionList me
>> set theProps to [:]
>>
>> set comment to "How many repetitions?"
>> set format to #integer
>> set default to 100
>> set repsProps to [#comment: comment, #format: format, #default: default]
>> addProp theProps, #reps, repsProps
>>
>> set c to "What message to send?"
>> set f to #string
>> set d to "jumpaBit"
>> set messageProps to [#comment: c, #format: f, #default: d]
>> addProp theProps, #secretMessage, messageProps
>>
>> return theProps
>> end
>>
>> -- And, f'rinstance:
>> on JumpaBit me
>> set origLoc to the loc of sprite spriteNum
>> repeat with i = 1 to 20
>> set deltaH to random(20) - 10
>> set deltaV to random(20) - 10
>> set the loc of sprite spriteNum to origLoc + point(deltaH, deltaV)
>> updateStage
>> end repeat
>> set the loc of sprite spriteNum to origLoc
>> end
Sorry, I'm sort of rambling here, but the "send" command was a special-case
thing that was more generally handled by regular parent/child type scripting,
and this whole strategy of private and persistent variables, as well as
targeting messages to specific sprites, has really opened up in the 1997 version
of Director.
Regards,
John Dowdell
Macromedia Tech Support
D. Plänitz