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
Follow the leader
Popup Text List Menu
Royalty free Music and Loops
CD Everywhere
Set Quality of a Flash Sprite
PC Guard for Win32 Xtra
CapsLockXtra
How To Change The Loader
Scrollable Sprites
QTGrab
 

 

 

Behavior MP3 Cross Fader

Added on 1/28/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: MarkDaggett

This little behavior will let you crossfade between MP3s. For those of you who don"t know what a "crossfade" is, its a musical term that means you fade one music source out while fading another one in. DJs use it all the time to fade out one record while fading the next one in. This behavior does the same thing except instead of records it uses MP3s. Cut and past the behavior below into a behavior script in your director project.

--written by mark daggett info@flavoredthunder.com
--Use this script till it wears out.
--Copyright Flavored Thunder Media 1999 All rights reserved.
property pMp3One
property pMp3Two
property pFaderSprite
property pFaderWidth
property pFlag --this allows the user to click on the sprite and start and stop the streams
property pFadePos
--this is the mp3 fader property
on beginSprite me
  set pFadePos = the mouseLoc  
  set pFlag = FALSE --false means that the MP3 is not playing
  set pFaderSprite = the currentSpriteNum
  set pFaderWidth = the width of sprite pFaderSprite
end
on MouseEnter me
  if pFlag = FALSE then
    set pFlag = TRUE
    play member pMp3One
    play member pMp3Two
  else
    set pFlag = FALSE
    stop member pMp3One
    stop member pMp3Two
  end if
end
on mouseWithin me
  if soundBusy(1) then
  else
    play member pMp3One
  end if
  if soundBusy(2) then
  else
    play member pMp3Two
  end if
  
  if pFlag = TRUE then
    if pFadePos > 0 and pFadePos < pFaderWidth/10 then
      set the volume of member pMp3One = 255  
      set the volume of member pMp3Two = 0
    else if pFadePos > (pFaderWidth/10)*1 and pFadePos <= (pFaderWidth/10)*2 then
      set the volume of member pMp3One = 28*9
      set the volume of member pMp3Two = 28*1
    else if pFadePos > (pFaderWidth/10)*2 and pFadePos <= (pFaderWidth/10)*3 then
      set the volume of member pMp3One = 28*8
      set the volume of member pMp3Two = 28*2
    else if pFadePos > (pFaderWidth/10)*3 and pFadePos <= (pFaderWidth/10)*4 then
      set the volume of member pMp3One = 28*7  
      set the volume of member pMp3Two = 28*3
    else if pFadePos > (pFaderWidth/10)*4 and pFadePos <= (pFaderWidth/10)*5 then
      set the volume of member pMp3One = 28*6
      set the volume of member pMp3Two = 28*4
    else if pFadePos > (pFaderWidth/10)*5 and pFadePos <= (pFaderWidth/10)*6 then
      set the volume of member pMp3One = 28*5  
      set the volume of member pMp3Two = 28*5
    else if pFadePos > (pFaderWidth/10)*6 and pFadePos <= (pFaderWidth/10)*7 then
      set the volume of member pMp3One = 28*4  
      set the volume of member pMp3Two = 28*6
    else if pFadePos > (pFaderWidth/10)*7 and pFadePos <= (pFaderWidth/10)*8 then
      set the volume of member pMp3One = 28*3  
      set the volume of member pMp3Two = 28*7
    else if pFadePos > (pFaderWidth/10)*8 and pFadePos <= (pFaderWidth/10)*9 then
      set the volume of member pMp3One = 28*2  
      set the volume of member pMp3Two = 28*8
    else if pFadePos > (pFaderWidth/10)*9 and pFadePos <= (pFaderWidth/10)*10 then
      set the volume of member pMp3One = 0  
      set the volume of member pMp3Two = 255
    end if
    
  else
    return
  end if
end
on exitFrame me
  set pFadePos = the mouseH
end


on getPropertyDescriptionList me
  set pdlist to [:]
  addprop pdlist, #pMp3One, [#comment:"Left mp3", #format:#string, #default:"mp3one"]
  addprop pdlist, #pMp3Two, [#comment:"Right mp3", #format:#string, #default:"mp3Two"]
  return pdlist
end getPropertyDescriptionList

 


Contact

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

Send e-mail