home *** CD-ROM | disk | FTP | other *** search
/ Encyklopedia Omnia / Planeta.iso / data / m_info.dir / 00008_Script_TextThumbScroll < prev    next >
Text File  |  2000-10-16  |  4KB  |  101 lines

  1. property minVloc, maxVloc, NStesto, upArrowSN, downArrowSN, totalTextHeight,¼
  2.           spaceFromArrows, thumbMinY, thumbMaxY, thumbX, thumbName, pagina
  3.  
  4. on beginSprite
  5.   set upArrowSN = (the currentSpriteNum) - 1
  6.   set downArrowSN = (the currentSpriteNum) + 1
  7.   set thumbName = the name of member the member of sprite NStesto
  8.   initSprite
  9. end
  10.  
  11. on initSprite
  12.   set alto = the bottom of sprite (NStesto+1)
  13.   set basso = the top of sprite (NStesto+2)
  14.   set pagina = basso - alto
  15.   set totalTextHeight = the PageHeight of member the member of sprite NStesto
  16.   
  17.   -- per le freccie
  18.   set maxVloc = the locV of sprite NStesto
  19.   set minVloc = pagina + maxVloc - the pageHeight of member the member of sprite NStesto
  20.   if minVloc > maxVloc then
  21.     set minVloc = maxVloc
  22.     set the cursor of sprite (the currentSpriteNum) to 0
  23.   else
  24.     set the cursor of sprite (the currentSpriteNum) to [member "palmo", member "palmo_m"]
  25.   end if
  26.   
  27.   -- per il thumb
  28.   set upDisplace =  getAt(the regPoint of member the member of sprite the currentSpriteNum,2)
  29.   set downDisplace = (the height of sprite the currentSpriteNum) - upDisplace
  30.   set thumbMinY = (the bottom of sprite upArrowSN) + upDisplace + spaceFromArrows
  31.   set thumbMaxY = (the top of sprite downArrowSN) - downDisplace - spaceFromArrows
  32.   set thumbX = the locH of sprite the currentSpriteNum
  33.   set the loc of sprite the currentSpriteNum to point(thumbX,thumbMinY)
  34. end
  35.  
  36. on arrowScroll me, pNewVloc
  37.   if minVloc <> maxVloc then
  38.     set newVloc = pNewVloc
  39.     if newVloc < minVloc then set newVloc to minVloc
  40.     if newVloc > maxVloc then set newVloc to maxVloc
  41.     set the locV of sprite NStesto to newVloc
  42.     
  43.     -- traccia lo scroll sul thumb
  44.     set scrollExtent = thumbMaxY - thumbMinY
  45.     set currentScrollTop = maxVloc - newVloc
  46.     
  47.     set diff = totalTextHeight - pagina
  48.     if diff <> 0 then
  49.       set newY = thumbMinY + scrollExtent*(currentScrollTop/float(diff))
  50.       -- sposta il thumb
  51.       set the loc of sprite the currentSpriteNum to point(thumbX, newY)
  52.     end if
  53.     
  54.     updateStage
  55.   end if
  56. end
  57.  
  58. on mouseDown
  59.   if minVloc <> maxVloc then
  60.     -- settings iniziali
  61.     set ns = the currentSpriteNum
  62.     set the cursor of sprite (ns) to [member "pugno", member "pugno_m"]
  63.     set totalTextHeight = the PageHeight of member the member of sprite NStesto
  64.     set scrollExtent = thumbMaxY - thumbMinY
  65.     set oldY = the locV of sprite ns
  66.     
  67.     set offset = getAt(the clickLoc, 2) - the locV of sprite ns
  68.     
  69.     -- loop sul mouseDown
  70.     repeat while the mousedown
  71.       set newY = mouseV() - offset
  72.       if newY > thumbMaxY then set newY = thumbMaxY
  73.       if newY < thumbMinY then set newY = thumbMinY
  74.       
  75.       -- se necessario...
  76.       if newY <> oldY then
  77.         -- sposta il thumb
  78.         set the loc of sprite ns to point(thumbX, newY)
  79.         set oldY = newY
  80.         
  81.         -- e scrolla il testo
  82.         set newScrollTop = (totalTextHeight - pagina) * ((newY - thumbMinY)/float(scrollExtent))
  83.         set newTxtY = maxVloc - newScrollTop
  84.         set the locV of sprite NStesto to newTxtY
  85.       end if
  86.       
  87.       updateStage
  88.     end repeat
  89.     
  90.     set the cursor of sprite (ns) to [member "palmo", member "palmo_m"]
  91.   end if
  92. end
  93.  
  94. on getPropertyDescriptionList
  95.   set p_list = [#NStesto: [#comment:"Numero sprite testo:",¼
  96.                 #format: #integer, #default: 1],¼
  97.                 #spaceFromArrows: [#comment:"Spaziatura tra freccie e thumb:",¼
  98.                 #format: #integer, #default: 2]]
  99.   
  100.   return p_list
  101. end