Turning graphic effects off and on

Richmond richmondmathewson at gmail.com
Mon Dec 9 14:50:18 EST 2013


On 09/12/13 21:34, Devin Asay wrote:
> Hi folks,
>
> I think I've done this, but I can't for the life of me remember how. In the property inspector for an object you can set up a graphic effect, and then use the checkbox to turn the effect off and on. LC somehow remembers your settings. But I want to do this by scripting. I know I can set each key of the effect separately, like this:
>
>    set the colorOverlay["color"] of btn "foo" to "1,2,3"
>    set the colorOverlay["opacity"] of btn "foo" to 160
>    etc.
>
> But is there a way to simulate just checking and unchecking the checkbox in the property inspector in a script?
>
> Devin
>
>

Well, as a person who goes in for the steam-shovel approach to 
programming here's a crude solution:

To turn ON effects:

First time around

on mouseUp
         set the colorOverlay["color"] of btn "foo" to "1,2,3"
         set the colorOverlay["opacity"] of btn "foo" to 160
         put the colorOverlay["color"] of btn "foo" into fld "fooColor"
         put the colorOverlay["opacity"] of btn "foo" into fld "fooOpake"
end mouseUp

To turn OFF effects

on mouseUp
        set the colorOverlay["color"] of btn "foo" to empty
        set the colorOverlay["opacity"] of btn "foo" to empty
on mouseUp

To RESTORE effects

on mouseUp
      set the colorOverlay["color"] of btn "foo" to fld "fooColor"
      set the colorOverlay["opacity"] of btn "foo" to fld "fooOpake"
end mouseUp

To be quite honest I don't know if that last lot will work, or you will 
have to put the contents of fld "fooColor"
into some intermediate variable like this:

on mouseUp
       put fld "fooColor" into fooColor
       set the colorOverlay["color"] of btn "foo" to fooColor
       put fld "fooOpake" into fooOpake
       set the colorOverlay["opacity"] of btn "foo" to fooOpake
on mouseUp

those hairy-chested types who feel at home with customProps could 
probably use those instead of fields.

Richmond.




More information about the use-livecode mailing list