home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 5 / boot-disc-1997-01.iso / media / utility.cst / 00017_Script_SoundClass < prev    next >
Text File  |  1996-11-05  |  3KB  |  104 lines

  1. property spritenum,minval,maxval,orient,changeflag,soundtextlist,ancestor
  2.  
  3. on new me,myminval,mymaxval,myorient
  4.   global SoundObj
  5.   set soundtextlist=["mute","very quiet","quiet","average","medium loud","loud","very loud","speaker bustin'"]
  6.   if voidP(myorient) then
  7.     set orient=#hor
  8.   else
  9.     set orient=myorient
  10.   end if
  11.   set minval=myminval
  12.   set maxval=mymaxval
  13.   set spritenum=castsprite("soundThumb")
  14.   if spritenum=0 then
  15.     alert("Can't find a cast member named 'soundThumb'")
  16.     halt
  17.   end if
  18.   puppetsprite spritenum,true
  19.   setsoundpos(me)
  20.   set SoundObj=me
  21.   --  clearactorlist me
  22.   --  add the actorlist,me
  23.   set ancestor=new(script "GenericClass")
  24.   return me
  25. end
  26.  
  27. on clearactorlist me
  28.   set olddelimiter=the itemdelimiter
  29.   set the itemdelimiter=quote
  30.   repeat with obj in the actorlist
  31.     if item 2 of string(obj)="SoundClass" then
  32.       if spritenum=the spritenum of obj then
  33.         set pos=getpos(the actorlist,obj)
  34.         deleteat the actorlist,pos
  35.         exit repeat
  36.       end if
  37.     end if
  38.   end repeat
  39. end
  40.  
  41.  
  42. on setsoundpos me
  43.   set curlevel=the soundlevel-1
  44.   set curpos=minval+curlevel*(maxval-minval)*1.0/7
  45.   if orient=#hor then
  46.     set the locH of sprite spritenum to curpos
  47.   else
  48.     set the locV of sprite spritenum to curpos
  49.   end if
  50.   updateStage
  51. end
  52.  
  53. on stepframe
  54.   if changeflag then
  55.     repeat while the mousedown
  56.       if orient=#hor then
  57.         set curpos=min(max(the mouseH,minval),maxval)
  58.         set the locH of sprite spritenum=curpos
  59.         updateStage
  60.       else
  61.         set curpos=min(max(the mouseV,minval),maxval)
  62.         set the locV of sprite spritenum=curpos
  63.         updateStage
  64.       end if
  65.       set curlevel=(7*(curpos-minval)*1.0/(maxval-minval))+1
  66.       set the soundlevel=curlevel
  67.       global gStatus
  68.       setbtntext gStatus,"soundThumb","The volume is "&getat(soundtextlist,curlevel)&"."
  69.       if not the mousedown then 
  70.         setbtntext gStatus,"soundThumb","Changes the volume."
  71.         set changeflag=false
  72.       end if
  73.     end repeat
  74.   end if
  75. end
  76.  
  77. on setsoundlevel me
  78.   repeat while the mousedown
  79.     if orient=#hor then
  80.       set curpos=min(max(the mouseH,minval),maxval)
  81.       set the locH of sprite spritenum=curpos
  82.       updateStage
  83.     else
  84.       set curpos=min(max(the mouseV,minval),maxval)
  85.       set the locV of sprite spritenum=curpos
  86.       updateStage
  87.     end if
  88.     set curlevel=(8*(curpos-minval)*1.0/(maxval-minval))
  89.     set the soundlevel=curlevel
  90. --    global gStatus
  91. --    setbtntext gStatus,"soundThumb","The volume is "&getat(soundtextlist,curlevel)&"."
  92. --    if not the mousedown then 
  93. --      setbtntext gStatus,"soundThumb","Changes the volume."
  94. --      set changeflag=false
  95. --    end if
  96.   end repeat
  97. end
  98.  
  99. on dispose me
  100.   puppetsprite spritenum,false
  101.   clearactorlist me
  102.   set me=0
  103. end
  104.