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
Replace embedded fonts in text/field and button members
Wait for MPEG with MCI commands
SinTaxer
DrawXtra
changing the color of a flash movie clip with lingo
Image Resizer v1.0
Moving MIAWs with lingo
Toggle Stay On Top
Set Properties of a Flash Sprite
Easy Mui
 

 

 

Behavior sound volum

Added on 5/12/2004

 

Compatibilities:
D8 D8_5 D9 Mac PC

This item has not yet been rated

Author: bluesun

sound volum control


property pMaxVolume, pVolume, Soundchanal

property extentSprite
property hiliteMember  -- looks like the handle plus hilite graphics
-- also holds the member of handle while hilited

property tracking
property newLocH
property newLocV

property dynamic   -- if true and sending true, sends value while tracking

property min, max  -- the range the slider maps to
property valrange  -- the difference of max and min, set on begin
property minScreen, maxScreen -- calculated from the screen coords of the extent
property currentScreenVal -- the data point in screen coords, set in tracking
property extentlength -- in screen coords, set on begin

property CurrentVal

on getPropertyDescriptionList
  if the currentspritenum = 0 then
    memdefault = 0
  else
    memref = sprite (the currentspritenum).member
    memdefault = member (the membernum of member memref + 1)
  end if
  
  
  set description = [:]
  
  addProp description, #Soundchanal, [#default: 1, #format:#integer, #comment: "Sound chanel:"]
  
  addprop description, #extentSprite, [#default: 1, #format:#integer, #comment: "Extent Sprite:"]
  
  addprop description, #hiliteMember, [#default: memdefault , #format:#graphic,#comment: "Hilite Member:"]
  
  addprop description, #dynamic, [#default: 1, #format:#boolean,#comment: "Dynamic:"]
  
  return description
end

on getBehaviorDescription
  return "Drag to slider 'handle' to enable control of video volume.  Requires additional 'extent' member which limits the handle travel range." & RETURN & "PARAMETERS:" & RETURN & "• Video Sprite - Enter the number of sprite channel in which video is displayed." & RETURN & "• Extent Sprite -  Enter the number of sprite channel that contains the 'extent' sprite."  & RETURN & "• Hilite Member -  Member to display while handle is being dragged."  & RETURN & "• Dynamic - If set, video time will be updated while handle is dragged, else when handle is released."
end

on compute_val me
  -- relies on tracking to update the currentScreenVal (different for Hor, Vert)
  set val = 0.0
  set val = float(the currentScreenVal of me) / float (the extentlength of me)
  set val = val * the valrange of me
  set val = val + the min of me
  return val
end

on send_the_val me, val
  -- sets the digital video volume to the val * paramter
  pVolume = val * pMaxVolume
  sound(Soundchanal).volume = pVolume
end


on beginSprite me
  
  set pMaxVolume = 255
  
  set the min of me = 0.0
  set the max of me = 1.0

  set handle = the spritenum of me
  set the tracking of me = FALSE
  set the newLocH of me = the locH of sprite handle
  set the newLocV of me = the locV of sprite handle
  
    set the newLocV of me = the locV of sprite the extentSprite of me
    set the minScreen of me = the left of sprite the extentSprite of me
    set the maxScreen of me = the right of sprite the extentSprite of me
  
  set the locH of sprite handle to the newLocH of me
  set the locV of sprite handle to the newLocV of me
  
  set the valrange of me = the max of me - the min of me
  set the extentlength of me = the maxScreen of me - the minScreen of me
  
end

on prepareFrame me
  -- limits motion of handle to extents of extentSprite
  -- and locks the handle to the track of the extentSprite
  
  if tracking then
    set handle = the spriteNum of me
    set extent =  the extentSprite of me
    
      set the newLocH of me = the mouseH
      set the newLocV of me = the locV of sprite extent
      if the newLocH of me < the left of sprite extent then
        set the newLocH of me = the left of sprite extent
      end if
      if the newLocH of me > the right of sprite extent then
        set the newLocH of me = the right of sprite extent
      end if
      
      set the currentScreenVal of me = the newLocH of me - the minScreen of me
      
    set the locH of sprite handle to the newLocH of me
    set the locV of sprite handle to the newLocV of me
    
    if the dynamic of me then
      send_the_val me, compute_val (me)
    end if
    
  else   --  end if tracking, control slider position by movieTime
    
    set x = float(sound(Soundchanal).volume)/ float(pMaxVolume)  
    
    set handle = the spriteNum of me
    set extent =  the extentSprite of me
    
      set ScreenX = the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
      set the newLocH of me = screenX
      set the newLocV of me = the locV of sprite extent
      if the newLocH of me < the left of sprite extent then
        set the newLocH of me = the left of sprite extent
      end if
      if the newLocH of me > the right of sprite extent then
        set the newLocH of me = the right of sprite extent
      end if
      
      set the currentScreenVal of me = the newLocH of me - the minScreen of me
    
    set the locH of sprite handle to the newLocH of me
    set the locV of sprite handle to the newLocV of me
    
  end if
end

on mouseDown me
  set tracking = TRUE
  set temp = the member of sprite the spritenum of me
  set the member of sprite the spritenum of me = member the hiliteMember of me
  set the hiliteMember of me = temp
end

on mouseUp me
  set tracking = FALSE
  set temp = the member of sprite the spritenum of me
  set the member of sprite the spritenum of me = member the hiliteMember of me
  set the hiliteMember of me = temp
  
end

on mouseUpOutside me
  set tracking = FALSE
  set temp = the member of sprite the spritenum of me
  set the member of sprite the spritenum of me = member the hiliteMember of me
  set the hiliteMember of me = temp
  
end



  

 


Contact

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

Send e-mail