home *** CD-ROM | disk | FTP | other *** search
/ PC Play 2 (Suomi) / PCPLAY2_2.ISO / play / main.dxr / 00040_SliderObj.ls < prev    next >
Encoding:
Text File  |  1998-02-15  |  965 b   |  46 lines

  1. property theSprite, theTop, theBottom, theMin, theMax, theValue, theCurLoc
  2.  
  3. on new me, spr, t, b, min, max, value
  4.   set theSprite to spr
  5.   set theTop to t
  6.   set theBottom to b
  7.   set theMin to min
  8.   set theMax to max
  9.   set theValue to value
  10.   set theCurLoc to ValueToV(me, value)
  11.   return me
  12. end
  13.  
  14. on Init me
  15.   puppetSprite(theSprite, 1)
  16.   set the locV of sprite theSprite to theCurLoc
  17. end
  18.  
  19. on move me
  20.   set theCurLoc to the mouseV
  21.   if theCurLoc < theTop then
  22.     set theCurLoc to theTop
  23.   else
  24.     if theCurLoc > theBottom then
  25.       set theCurLoc to theBottom
  26.     end if
  27.   end if
  28.   set the locV of sprite theSprite to theCurLoc
  29. end
  30.  
  31. on EndMove me
  32.   set theValue to VToValue(me, theCurLoc)
  33. end
  34.  
  35. on VToValue me, v
  36.   return theMax - integer(float(v - theTop) / (theBottom - theTop) * (theMax - theMin))
  37. end
  38.  
  39. on ValueToV me, value
  40.   return (float(theMax - value) / (theMax - theMin) * (theBottom - theTop)) + theTop
  41. end
  42.  
  43. on Dispose me
  44.   puppetSprite(theSprite, 0)
  45. end
  46.