Lingo for Sliders

Ideas supplied by...
  1. Bosaiya
  2. Nguyen Thuy Linh
  3. Roger Jones

Sliders from Bosaiya

Date:    Mon, 14 Nov 1994 11:52:40 -0800
From:    Bosaiya 
Subject: Re: sliders
This is a reconstruction and modification of a script by Gary Sadavage, which will keep track of where your position is and post the location to a text field (which you can easily change to a variable).

Or you can buy the CD "Interactive Buttons and Controls" by Staz Software.

on initSlider
  global  L
  puppetsprite 5, true (5 is the slider handle)
  set L = the left of sprite 4
end
 
on goSliding
  global L
 
  puppetsprite 5,true
  puppetsprite 2,true
 
   repeat while the stillDown
    set newH = constrainH(4,mouseH())
    set the locH of sprite 5 to newH
    set newValue = (newH - L)/increment
    setMeterValue newValue   -- (this displays the current position in a text field)
    updateStage
   end repeat
   updatestage
end
 
on setMeterValue value
  set the text of cast "Position" to string (value)
end

Sliders from Nguyen Thuy Linh

Date:    Tue, 15 Nov 1994 12:09:06 +1100
From:    Nguyen Thuy Linh 
Subject: Re: sliders
First make the slider movable by checking the Movable property on the left-hand side in the Score window for the slider sprite.

To constrain the movement of the slider :

  1. Create a shape cast of the desired shape (should be a thin rectangular in this case)
  2. On the stage, position this shape on the bar of the slider
  3. Write a frame script for the frame where the slider, the shape and the bar are, something like :
    on exitFrame
      go to the frame
    end
     
    on mouseDown
      set the constraint of  sprite to 
    end
     
  4. To return various numeric values as the slider are dragged along a horizontal bar :
    on mouseUp
      if the locH of <slider> sprite = <certain value> then
        put <the return value> into <your var>
      else if the locH of <slider> sprite = <other value> then
        put <other return value> into <your var>
      else ......
     
      end if 
    end
    
You can read the "Using Lingo" manual, page 142-143, and also 126-128 about puppet sprite.

Sliders by Roger Jones

Date:    Wed, 12 Jan 1994 01:27:10 -0800
From:    Roger Jones 
Subject: Re: Audio fader(s) for director
Here's some code for a horizontal slider that sets qt volume:
--Quicktime volume control using lingo
--Based on slider example by Chuck Walker
--Example by Roger Jones 1/92
--Revised 1/95
 
on startMovie
  global increment,L,qtsprite,sliderbarsprite,sliderthumbsprite,maxVolume
  set qtsprite = 3 -- the quicktime movie's sprite channel
  set sliderbarsprite = 11 -- the slider bar's sprite channel
  set sliderthumbsprite = 12 --the slider thumb's  sprite channel
  -- OverDriveRate allows you to overdrive the sound to increase its max volume.
  -- Sort of like having 11 on your Marshall stack
  --Try values from 1 to 4. Default is 1
  set overDriveRate = 1
  set maxVolume = overdriveRate * 255
  PuppetSprite sliderthumbsprite,TRUE -- For slider.
  --set the immediate of sprite sliderthumbsprite to TRUE -- arcane lingo
  set increment = float(maxVolume/the width of sprite sliderbarsprite)
  set L = the left of sprite sliderbarsprite
  updatethumb --updates the thumb to the current volume setting
end
Attach this script to the slider thumb in the score using on mouseDOWN.
on mouseDown
  SliderActive
end
 
on SliderActive
  global increment,L,qtsprite,sliderbarsprite,sliderthumbsprite,maxVolume
  if the type of sprite qtsprite <> 16 then exit -- optional error check
 
  repeat while the stillDown
    set newH = constrainH(sliderbarsprite,mouseH())
    set the locH of sprite sliderthumbsprite = newH
    set the volume of sprite qtsprite  =  ( newH - L ) * increment
    updateStage
  end repeat 
end
Use this to update the thumb if necessary
on updatethumb
  global increment,L,qtsprite,sliderbarsprite,sliderthumbsprite
  if the type of sprite qtsprite <> 16 then exit -- optional error check
  set the locH of sprite sliderthumbsprite = (the volume of sprite qtsprite / increment) + L
end