von Daniel am 22.Dezember 96 um 15:11:49:
zu: Perlen aus dem Strom der Nachrichten im direct_L von Daniel am 22.Dezember 96 um 02:00:59:
>It is the same syntax than parent script. You can pass parameters also:
>
>handler1 (script theNameOfMember, param1,...)
>
>Then in script of member of name theNameOfMember ...
>
>on handler1 me, param1,...
>end handler1
>
>the "me" here will not contains an object reference, but the string "script
>theNameOfMember" (theNameOfMember will resolve to a string).
It's not *really* a string, it just shows up that way in the message
window or using the Lingo string() function.
This may seem like a picky point, but the 'me' there
absolutely *is* an object reference-- the script itself is an object.
Notice that objectP(script 23) is *true*. This also means that
scripts *themselves* can have their own properties, without ever
birthing any children. This can be used to great advantage to
keep your global name space uncluttered.
Consider the following frame script:
property alreadyInitialized
on enterFrame me
if not objectP(me) then return enterFrame(script the frameScript)
if voidP(alreadyInitialized) then
set alreadyInitialized = 1
--Do one-time initialization tasks
end if
--Other enterFrame stuff to do every frame
end
The first time this frame is entered, some setup chores will be performed.
There's no need for the old 3-frame trilogy 'set up frame, work frame,
clean up frame'; and each frame script has its own private copy of
alreadyInitialized.
A similar approach can be taken with mouseUp cast member scripts...
property alreadyInitialized
on mouseDown me
if not objectP(me) then return mouseDown(script the mouseCast)
...
end
Or with mouseUp sprite scripts...
property alreadyInitialized
on mouseDown me
if not objectP(me) then
return mouseDown(script (the scriptNum of sprite the clickOn))
end if
...
end
Alternatively, you can just make your handlers aware of whether they've
been triggered by a genuine user interface event, or have been
triggered by other scripts sending messages to them...
on mouseDown me
if not objectP(me) then
--Real mouse down
else
--Simulated mouse down
end if
end
There was an involved thread about using the properties of script objects maybe
a year ago under the subject 'Eureka!', and/or 'script object' or
'script property' or 'property of script' or somesuch.
Recompiling a script, incidentally, clears any property variable values that
have been set for the script object. You just have to be aware of
that while authoring.
- Glenn M. Picher Dirigo Multimedia gpicher@maine.com (207)767-8015
D. Plänitz