home *** CD-ROM | disk | FTP | other *** search
/ GameStar 1998 November (Bonus) / GAMESTAR11B.ISO / ENCYC99 / MM / T065518A.DCR / 00019_ProgressBarMaker.ls < prev    next >
Encoding:
Text File  |  1998-06-18  |  3.0 KB  |  132 lines

  1. property numFrames, barLength, barMap, handleChannel, maskChannel, barChannel, startLocH, endLocH, barHideLeft, barHideTop, barHideBottom, handleCast, playing, storedPlaying, theTransitions, movieChunk, thenFrame
  2. global SoundTracker
  3.  
  4. on new me, hChannel, mChannel, bChannel, tFrames
  5.   global transitionFrames
  6.   set playing to 0
  7.   set storedPlaying to playing
  8.   set handleChannel to hChannel
  9.   set handleCast to the memberNum of sprite handleChannel
  10.   set maskChannel to mChannel
  11.   set barChannel to bChannel
  12.   set thatFrame to the frame
  13.   set theTransitions to transitionFrames
  14.   if the lastFrame > 50 then
  15.     set movieChunk to the lastFrame / 50
  16.   else
  17.     set movieChunk to 1
  18.   end if
  19.   initBarMap(me)
  20.   initBarHide(me)
  21.   stopTheMovie(me)
  22.   return me
  23. end
  24.  
  25. on initBarMap me
  26.   set startLocH to the left of sprite barChannel + 1
  27.   set endLocH to the right of sprite barChannel - 1
  28.   set numFrames to the lastFrame
  29.   set barLength to endLocH - startLocH
  30.   set barMap to [:]
  31.   repeat with i = 0 to barLength
  32.     set whichFrame to i * numFrames / barLength
  33.     if whichFrame = 0 then
  34.       set whichFrame to 1
  35.     end if
  36.     addProp(barMap, startLocH + i, whichFrame)
  37.   end repeat
  38. end
  39.  
  40. on initBarHide me
  41.   set barHideLeft to the left of sprite maskChannel
  42.   set barHideTop to the top of sprite maskChannel
  43.   set barHideBottom to the bottom of sprite maskChannel
  44. end
  45.  
  46. on progTrack me, nowFrame
  47.   global doTransition
  48.   if not playing then
  49.     soundOff(SoundTracker)
  50.   else
  51.     soundOn(SoundTracker)
  52.     if nowFrame <> thenFrame then
  53.       set thisTransition to getaProp(theTransitions, nowFrame + 1)
  54.       if not voidp(thisTransition) then
  55.         set doTransition to thisTransition
  56.       else
  57.         set doTransition to 0
  58.       end if
  59.     end if
  60.   end if
  61.   if the stillDown and (the clickOn = handleChannel) then
  62.     soundOff(SoundTracker)
  63.     set checkIt to the mouseH
  64.     if checkIt <= startLocH then
  65.       go(1)
  66.     else
  67.       if checkIt >= endLocH then
  68.         go(the lastFrame)
  69.       else
  70.         set tempFrame to getProp(barMap, checkIt)
  71.         go(tempFrame)
  72.       end if
  73.     end if
  74.   else
  75.     if not playing then
  76.       go(nowFrame)
  77.     end if
  78.   end if
  79.   set tempFrame to nowFrame
  80.   set tempLoc to getOne(barMap, tempFrame)
  81.   repeat while tempLoc = 0
  82.     set tempFrame to tempFrame + 1
  83.     set tempLoc to getOne(barMap, tempFrame)
  84.   end repeat
  85.   set the rect of sprite maskChannel to rect(barHideLeft, barHideTop, tempLoc, barHideBottom)
  86.   set the locH of sprite handleChannel to tempLoc
  87.   set thenFrame to nowFrame
  88. end
  89.  
  90. on storePlaying me
  91.   set storedPlaying to playing
  92. end
  93.  
  94. on resetPlaying me
  95.   if storedPlaying then
  96.     PPButtonPlay()
  97.   else
  98.     PPButtonPause()
  99.   end if
  100. end
  101.  
  102. on stopTheMovie me
  103.   pauseMovie(me)
  104.   progTrack(me, 1)
  105. end
  106.  
  107. on playMovie me
  108.   set playing to 1
  109. end
  110.  
  111. on pauseMovie me
  112.   set playing to 0
  113. end
  114.  
  115. on RewMovie me, nowFrame
  116.   set tempFrame to nowFrame - movieChunk
  117.   if tempFrame < 1 then
  118.     go(1)
  119.   else
  120.     go(tempFrame)
  121.   end if
  122. end
  123.  
  124. on FFMovie me, nowFrame, eFrame
  125.   set tempFrame to nowFrame + movieChunk
  126.   if tempFrame > eFrame then
  127.     go(eFrame)
  128.   else
  129.     go(tempFrame)
  130.   end if
  131. end
  132.