Listen for messages in FrontScripts

Todd Geist todd at geistinteractive.com
Mon Jan 2 13:54:41 EST 2012


On Sun, Jan 1, 2012 at 8:38 PM, Mark Wieder <mwieder at ahsoftware.net> wrote:

> Todd-
>
> Sunday, January 1, 2012, 4:40:47 PM, you wrote:
>
> Why would you want to do this? The only time I issue a dispatch
> without a target is in a behavior script, and in that case the message
> is delivered to the parent object, which is a very neat trick, and I
> think is the equivalent of ruby's yield command.



Well mostly I am just trying to understand how things things work.  I *
thought* that messages released from front scripts might rain down on top
most stack.  This is not true, clearly.

I was using metaphor in my own head of messages "raining" down on your
stacks.  I don't like this metaphor any more. I don't think it fits.

If I am getting this right now.  All messages have an explicit initial
target, which is the point at which they enter the message path. A
frontscipt is inserted *before* that target ( and all targets ). If it
doesn't handle the message or if it passes it, that message continues on to
its original target and then down through the normal message path.

LiveCode out of the box doesn't have Event Listerners  that can hear events
from anywhere.  Objects can only hear messages that are directed at them or
have been passed down through the message path.  Part of what got me into
this was trying to create Event Listeners.

Trevor does this in GLX and calls it "broadcasting". I have some Flex and
JavaScript experience which leads me to favor calling it "Event Listeners".

This turns out to be startling easy with LiveCode. Its less than 50 lines
of code. Maybe 55 lines if you include the lines needed to load the
frontscript.  Objects can "Listen" for events and Object can Send events.
 Neither side needs to know anything about the other.  I chose to do it
with a FrontScript, because I felt it would be faster then using a library
at the end of the message path.

Todd



More information about the use-livecode mailing list