Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Which Keys
Dave Client
simPPTEdit 1.0 Xtra
bambino
Generic behavior to check Windows Platform
Get Dropped Files
Royalty free Music and Loops
Progress Bar
Select Button With Rollover Effect
EasyBase
 

 

 

Behavior Volume Slider

Added on 7/19/1999

 

Compatibilities:
behavior D7 D8 Mac PC

This item has not yet been rated

Author: RainerÖhman

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

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail