Chained Behaviors
J. Landman Gay
jacque at hyperactivesw.com
Fri Jul 12 14:36:49 EDT 2013
On 7/12/13 12:04 PM, Peter Haworth wrote:
> Has anyone got any real world examples of the benefits of the new chained
> behaviors feature?
>
> I just read the latest newsletter article about them and while I understand
> the concept, I didn't see benefit in the example scenario over a single
> behavior with some common logic and a switch statement to handle the logic
> specific to each "sprite".
I needed chained behaviors a while ago before they were available, and
was required to copy duplicate sections of scripts into each of several
behaviors. If I get time I'll go back and chain them now that it is
available.
Remember that behaviors are not a single handler, they are whole
scripts. I have several sprites that require different behaviors on
mouseUp but they all have the same behaviors on mouseDown. With a
chained behavior, I could have placed the mouseDown handler into the
"top" of the chain and different mouseUp handlers in each separate
behavior script underneath that:
on mouseDown
doDownStuff
end mouseDown
/ \
on mouseUp on mouseUp
doBehavior1 doBehavior2
end mouseUp end mouseUp
The mouseDown handler was semi-lengthy and I would have prefered not
repeating it in each behavior script.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list