Creating a reusable object - Part 2
J. Landman Gay
jacque at hyperactivesw.com
Thu Aug 9 16:37:29 EDT 2012
On 8/8/12 11:37 PM, Mark Smith wrote:
>
> I haven't played with back scripts so I'm not sure how I would
> get that working (or how different it would be from just having a stack
> script... but feel free to enlighten me... please!)
Backscripts and frontscripts are just scripts in the message hierarchy
that don't need to be attached to any object. They are stored in an
object so they will be saved with the stackfile, but once inserted, the
object isn't referenced at all. Frontscripts receive messages before
your stack does. Backscripts receive messages after everything else
(after the stack script.)
Inserted scripts are global; that is, they will be in the message path
of any stack. If your backscript is useful only for one particular
stack, it's customary (and polite) to insert it when that stack opens
and remove it when the stack closes.
Since you're interested in the resizestack handler, you could create a
button with a script that has a resizestack handler in it. At some point
before it's needed a script should:
insert script of btn x into back
When the engine sends a resizeStack message, it will go through the
message path normally and if there is no handler in the card or stack to
catch it, the backscript will catch it and execute its commands.
Since you want to respond only to certain cards, I'd mark those cards
somehow, with a custom property probably, and have the handler check to
see if it should act. Although in this situation your group method may
actually be easier, since the handler will only fire on cards that have
the group. I tend to avoid excess objects whenever possible so I'd
probably go for the backscript, but that's mostly just a style preference.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list