before vs on in behavior scripts - red herring alert!

Richard Gaskin ambassador at fourthworld.com
Thu Mar 20 11:54:25 EDT 2014


Devin Asay wrote:

 > Later I discovered that *someone* (I blame the code kabouters*) had
 > gone in and assigned icon states to the buttons using the behaviors,
 > rendering the BEFORE and AFTER handlers redundant.

I like "kabouters".  I have a friend who refers to unexpected behavior 
in software as the work of faeries.  I imagine Brahmanathswami blames 
the Menehuni.  I blame Coyote, the mischievous spirit the native 
Californians blamed for the inexplicable annoyances of their world. :)


 > So it appears that each time I launch the project I have to reassign
 > the behavior to the buttons. This only seems to happen for behaviors
 > stored in library stacks. I have seen a similar problem with objects
 > that were assigned a background pattern stored in a library stack.

As much as I love behaviors, the finicky way they're resolved has been 
an annoyance for me:  you have to make sure that any behavior script 
objects are loaded before any object that uses them.

For example, if you have a mainstack which is an executable and contains 
objects that use behaviors, and a separate library stackfile which 
contains the behavior buttons, it will always fail because that 
mainstack is opened before the library is loaded, so the resolution will 
be attempted before the objects they resolve to can be known.

The workaround is as you've discovered: you have to write code to 
reassign the behavior on the fly.

To simplify this occasional necessity, I had hoped the team would have 
implemented a command they once talked about in the early days of 
behaviors but never quite got around to: "resolve behaviors", which 
would trigger the same resolution mechanism that happens when stacks are 
first loaded, but could be called whenever you need it.

FWIW I submitted a request for that:
<http://quality.runrev.com/show_bug.cgi?id=8993>

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys





More information about the use-livecode mailing list