home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2000 February / DPPCPRO0200.ISO / ps10.dxr / Scripts_14_scrollParent.ls < prev    next >
Encoding:
Text File  |  1999-10-26  |  3.0 KB  |  83 lines

  1. property myFieldName, iGrabBarTop, iGrabBarBottom, iWindowTop, iWindowBottom, iTextSprite, iBarSprite, searchRatio1, searchRatio2, iDefaultTextTopLoc, iDefaultTextBottomLoc
  2.  
  3. on new me, fieldName, barTop, barBottom, textTop, textBottom, textSprite, barSprite
  4.   iGrabBarTop = barTop
  5.   iGrabBarBottom = barBottom
  6.   iWindowTop = textTop
  7.   iWindowBottom = textBottom
  8.   iTextSprite = textSprite
  9.   iBarSprite = barSprite
  10.   iDefaultTextTopLoc = the locV of sprite iTextSprite
  11.   iDefaultTextBottomLoc = the locV of sprite iTextSprite - (the bottom of sprite iTextSprite - iWindowBottom)
  12.   testDistance = iWindowTop - iDefaultTextBottomLoc
  13.   searchRatio1 = testDistance / float(iGrabBarBottom - iGrabBarTop)
  14.   searchRatio2 = float(iGrabBarBottom - iGrabBarTop) / testDistance
  15.   return me
  16. end
  17.  
  18. on buttonScroll me, direction
  19.   case direction of
  20.     #up:
  21.       if the top of sprite iTextSprite < iWindowTop then
  22.         set the locV of sprite iTextSprite to the locV of sprite iTextSprite + 5
  23.       else
  24.         set the locV of sprite iTextSprite to iWindowTop
  25.       end if
  26.     #down:
  27.       if the bottom of sprite iTextSprite > iWindowBottom then
  28.         set the locV of sprite iTextSprite to the locV of sprite iTextSprite - 5
  29.       else
  30.         set the locV of sprite iTextSprite to iWindowBottom - (the bottom of sprite iTextSprite - the top of sprite iTextSprite)
  31.       end if
  32.   end case
  33.   testLoc1 = iWindowTop - the locV of sprite iTextSprite
  34.   testLoc2 = testLoc1 * searchRatio2
  35.   newTextLoc = iGrabBarTop + testLoc2
  36.   set the locV of sprite iBarSprite to newTextLoc
  37. end
  38.  
  39. on grabScroll
  40.   newLoc = the mouseV
  41.   if newLoc <= iGrabBarTop then
  42.     set the locV of sprite iBarSprite to iGrabBarTop
  43.     set the locV of sprite iTextSprite to iDefaultTextTopLoc
  44.   else
  45.     if newLoc >= iGrabBarBottom then
  46.       set the locV of sprite iBarSprite to iGrabBarBottom
  47.       set the locV of sprite iTextSprite to iDefaultTextBottomLoc
  48.     else
  49.       set the locV of sprite iBarSprite to newLoc
  50.       testLoc1 = newLoc - float(iGrabBarTop)
  51.       testLoc2 = testLoc1 * searchRatio1
  52.       newTextLoc = iWindowTop - testLoc2
  53.       set the locV of sprite iTextSprite to newTextLoc
  54.     end if
  55.   end if
  56.   updateStage()
  57. end
  58.  
  59. on quickScroll me, locationOfClick
  60.   testClick = locationOfClick - iGrabBarTop
  61.   tempLocation = the locV of sprite iBarSprite - iGrabBarTop
  62.   if testClick < tempLocation then
  63.     newLoc = the locV of sprite iTextSprite + (iWindowBottom - iWindowTop - 20)
  64.     if newLoc > iDefaultTextTopLoc then
  65.       set the locV of sprite iTextSprite to iDefaultTextTopLoc
  66.     else
  67.       set the locV of sprite iTextSprite to newLoc
  68.     end if
  69.   else
  70.     newLoc = the locV of sprite iTextSprite - (iWindowBottom - iWindowTop - 20)
  71.     if newLoc < iDefaultTextBottomLoc then
  72.       set the locV of sprite iTextSprite to iDefaultTextBottomLoc
  73.     else
  74.       set the locV of sprite iTextSprite to newLoc
  75.     end if
  76.   end if
  77.   testLoc1 = iWindowTop - the locV of sprite iTextSprite
  78.   testLoc2 = testLoc1 * searchRatio2
  79.   newTextLoc = iGrabBarTop + testLoc2
  80.   set the locV of sprite iBarSprite to newTextLoc
  81.   updateStage()
  82. end
  83.