mercoledì 3 giugno 2015

Creare un pulsante spaventoso

Per creare un pulsante che dia un senso di inquietudine, tipo che pulsa, si possono scrivere pochie righe di livecode. Ad esempio per questo effetto:

basta utilizzare questo codice:

local tSize, tDirection

on mouseEnter
   # Set the pulse speed and animation basics
   set the idlerate to 40
   put "up" into tDirection
   put 1 into tSize   
   # Apply the outer glow (we'll only change the size in the
   # next handler)
   lock screen
   set the outerglow["opacity"] of me to 255
   set the outerglow["color"] of me to "0,0,0"
   set the outerglow["size"] of me to tSize   
   set the colorOverlay["color"] of me to "0,0,0"
   set the colorOverlay["opacity"] of me to "45"
   unlock screen
end mouseEnter

on mouseLeave
   # When the mouse leaves the buttons we simply clear the effect
   set the outerGlow of me to empty
   set the colorOverlay of me to empty   
end mouseLeave

on mouseWithin
   # Increment / decrement the size of the glow
   if tDirection is "up" then
      add 1 to tSize
   else
      subtract 1 from tSize
   end if   
   # Calculate the new direction of the pulse
   if tSize > 20 then
      put 19 into tSize
      put "down" into tDirection
   else if tSize < 0 then
      put 0 into tSize
      put "up" into tDirection
   end if   
   #Set the new size of the glow
   set the outerglow["size"] of me to tSize
end mouseWithin

E voi che effetti potreste fare?