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
Easy Templates Flash Website Kit
VbScript Xtra
Hide a range of sprite channels
Video Cleanup
Giving a shadow for a sprite
WebCamXtra - Computer Vision & Camera Tracking
KeyboardControl Xtra Lite
Power Blender
Lissajous Motion
A cool button
 

 

 

Behavior Volume Control Behavior

Added on 8/8/2000

 

Compatibilities:
behavior D7 D8 Mac PC

This item has not yet been rated

Author: Shehal (website)

use this behavior to specify which is the thumb and which is the slide bar

-- use this behavior to specify which is the thumb and which is the slide bar
-- visit my shockwave site
-- http://www.unixville.com/~shehal/
-- mailto: shehal@mediasolv.com
-- I work for MediaSolv.com
-- visit RISSA"s site
-- http://www.geocities.com/~marissaj/

global thumbSprite
global thumbWidth
global slideBarSprite
global slideBarLength
global maxX -- right corner of thumb
global minX -- left  corner of thumb
global Y -- the vertical position of slide bar
global leftLimit
global rightLimit

property controlObject
property canDragNow
property volumeLevel

on beginSprite me
  case controlObject of
    "thumb":
      thumbSprite = sprite(me.spriteNum)
      member(thumbSprite.member).centerRegPoint = 1
      thumbWidth = thumbSprite.width
      thumbSprite.locV = Y
    "slide bar":
      slideBarSprite = sprite(me.spriteNum)
      member(slideBarSprite.member).centerRegPoint = 1
      slideBarLength = slideBarSprite.width
      maxX = (slideBarSprite.locH) + (slideBarLength / 2) - (thumbWidth / 2)
      minX = (slideBarSprite.locH) - (slideBarLength / 2) + (thumbWidth / 2)
      Y = slideBarSprite.locV
  end case
end beginSprite

on mouseDown me
  canDragNow = 1
end mouseDown

on mouseWithin me
  if canDragNow = 1 then
    if (the mouseH < maxX) AND (the mouseH > minX) then
      set thumbSprite.locH = the mouseH
      X = thumbSprite.locH
      volumeLevel = 7*(pi()*(X-minX))/(pi()*(maxX-minX))
      set the soundLevel to integer (volumeLevel)
    else
      if (the mouseH = maxX) then
        set thumbSprite.locH = maxX
        volumeLevel = 7
        set the soundLevel to integer (volumeLevel)
      else
        if (the mouseH = minX) then
          set thumbSprite.locH = minX
          volumeLevel = 0
          set the soundLevel to integer (volumeLevel)
        end if
      end if
    end if
  end if
end mouseWithin

on mouseUp me
  set canDragNow = 0
end mouseUp

on mouseLeave me
  set canDragNow = 0
end mouseLeave

on getPropertyDescriptionList
  set description = [:]
  addProp description,#controlObject, [#default: "thumb", #range: ["thumb", "slide bar"], #format:#string, #comment:"What is this Sprite ?"]
  return description
end

 


Contact

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

Send e-mail