|
|
|
Volume Slider
Added on 7/19/1999
|
Drop it on your slider button and select either a sound channel or a sprite channel for your sound.
-- VolumeSlider behavior
-- Rainer Öhman, 1999
property spriteNum
property pSound
property pSoundName
property pVolumeBtnSprite
property pSliderConstraintSprite
property pZeroVolumeLoc
property pFullVolumeLoc
property pBtnLoc
on getPropertyDescriptionList
propList = [:]
addProp propList, #pSound, [¬
#default: 1, ¬
#format: #integer, ¬
#comment: "Sound channel:"]
addProp propList, #pSoundName, [¬
#default: "Sound member used as a sprite", ¬
#format: #string, ¬
#comment: "Sound name:"]
addProp propList, #pSliderConstraintSprite, [¬
#default: 1, ¬
#format: #integer, ¬
#comment: "Slider sprite number:"]
addProp propList, #pVolumeBtnSprite, [¬
#default: 2, ¬
#format: #integer, ¬
#comment: "Volume button sprite number:"]
return propList
end
on getBehaviorDescription
description = ¬
"Place the volume button in a channel number higher ¬
then the sprite you wish to function as a constraint ¬
for the button. Then drop this behavior on the button. ¬
Chose either a sound channel or the name of the sound ¬
used in a sprite channel."
return description
end
-----------------
on beginSprite me
sprite(pVolumeBtnSprite).constraint = pSliderConstraintSprite
sprite(pVolumeBtnSprite).moveableSprite = TRUE
sprite(pSliderConstraintSprite).width = 0
pFullVolumeLoc = sprite(pSliderConstraintSprite).top
pZeroVolumeLoc = sprite(pSliderConstraintSprite).bottom
sprite(pVolumeBtnSprite).locV = pFullVolumeLoc
end
on setVolume me
range = pZeroVolumeLoc - pFullVolumeLoc
volIndex = 255.0 / range
diff = pZeroVolumeLoc - pBtnLoc
v = diff * volIndex
if pSound then
set the volume of sound pSound = integer(v)
end if
if not(pSoundName = "Sound member used as a sprite") then
member(pSoundName).volume = integer(v)
end if
end
on exitFrame me
pBtnLoc = sprite(spriteNum).locV
setVolume
end
|
|