home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 152 / PCG152DA0905 / PCG152DA0905.mdf / Main.dxr / Scripts_14_rollover effect.ls < prev    next >
Encoding:
Text File  |  2005-07-15  |  1.6 KB  |  67 lines

  1. property pBegin, pEnd, pDur, pCount, pmode, spriteNum
  2.  
  3. on beginSprite me
  4.   pBegin = float(pBegin) / 100 * 255
  5.   pEnd = float(pEnd) / 100 * 255
  6.   pmode = #none
  7.   pCount = 0
  8.   pDur = pDur + 1
  9.   add(the actorList, me)
  10. end
  11.  
  12. on endSprite me
  13.   deleteOne(the actorList, me)
  14. end
  15.  
  16. on mouseEnter me
  17.   pCount = 1
  18.   pmode = #on
  19. end
  20.  
  21. on mouseLeave me
  22.   pCount = 1
  23.   pmode = #off
  24. end
  25.  
  26. on getBehaviorDescription
  27.   dMsg = EMPTY
  28.   dMsg = dMsg & "Apply to a sprite and set the initial and ending opacity value." & RETURN
  29.   dMsg = dMsg & "On a rollover the sprite will change opacity to the ending value." & RETURN
  30.   dMsg = dMsg & "On a mouseleave the sprite will return to the beginning opacity."
  31.   return dMsg
  32. end
  33.  
  34. on getPropertyDescriptionList
  35.   pList = [:]
  36.   addProp(pList, #pBegin, [#comment: "Beginning fade value (0-100%): ", #format: #integer, #default: 0])
  37.   addProp(pList, #pEnd, [#comment: "End fade value (0-100%): ", #format: #integer, #default: 100])
  38.   addProp(pList, #pDur, [#comment: "Duration (Frames):", #format: #integer, #default: 10])
  39.   return pList
  40. end
  41.  
  42. on stepFrame me
  43.   if pmode = #none then
  44.     exit
  45.   end if
  46.   if pmode = #on then
  47.     if pCount < pDur then
  48.       dBlend = float(pCount) / pDur * pEnd
  49.       sprite(spriteNum).blendLevel = dBlend
  50.       pCount = pCount + 1
  51.     else
  52.       if sprite(spriteNum).blendLevel <> pEnd then
  53.         sprite(spriteNum).blendLevel = pEnd
  54.         pCount = pCount + 1
  55.       end if
  56.     end if
  57.   else
  58.     if pmode = #off then
  59.       if pCount < pDur then
  60.         dBlend = 255 - (float(pCount) / pDur * pEnd)
  61.         sprite(spriteNum).blendLevel = dBlend
  62.         pCount = pCount + 1
  63.       end if
  64.     end if
  65.   end if
  66. end
  67.