Articles Archive
Articles Search
Director Wiki
 

Multiple rollOver sounds

July 6, 1998
by Pat McClellan

Dear Multimedia Handyman,

I would like to play several rollover sounds fully at the same time. If the first sound plays I would like to rollover the second button and play the next sound while the first sound is still playing. For the moment the first sound stops when the second is playing. I can't even hear several sounds at the same time, even without scripts.

and

After you have rollover all the buttons, all the sounds sould be playing at the same time, and then jump to another frame. Is it possible?

william / at / houseofblake.co.uk

Dear William,

First you should read my recent column on cross-platform sound. Make sure that you have enabled all 8 channels for sound on Windows.

The problem you're encountering has to do with the puppetSound command. When you play a puppetSound, it STOPS playing any other sound in that channel. If you have less than 8 buttons, you simply need to assign each of them to a different sound channel. Then, you can play them simultaneously.

A more versatile approach is to build a "sound server". This is simple behavior which scans through the sound channels and assigns the first free channel to your next sound. Attach this behavior to your buttons. You'll need to specify the particular sound file for each.


ServeSound rollover behavior
property soundFile
on getPropertyDescriptionList
  
  set p_list = [ #soundFile: [ #comment:   ¬
    "Sound File:", #format:   #string, ¬
        #default:   "" ] ]
  return p_list  
  
end

on mouseEnter me
    repeat with i = 1 to 8
        
          if soundBusy(i) then
               next repeat
          else 
               puppetSound i, soundFile
               updateStage
               exit
          end if
                  
     end repeat
         
end

NOTE: if all 8 sound channels are busy, your sound will not be played. If your sounds are relatively short in duration, you will rarely have all 8 sounds playing, so the server works pretty well.

To jump to another frame ONLY when all buttons have been rolled over, then you need to create a separate behavior to track the rolledOver status. Let's create a global variable called gRollList in your startMovie handler.


on startMovie
     global gRollList
     set gRollList = []
         
end

Now, each button will initially add itself to the list, and subsequently delete itself when it gets rolledOver. When the list is empty, then all buttons will have been rolledOver and you move on.

rolledOver watcher

global gRollList
on beginSprite
     add gRollList, me
         
end
on mouseEnter me
     deleteOne gRollList, me
     if count(gRollList) = 0 then
          go to frame "whatever"
     end if
         
end

Good luck with your program.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2024, Director Online. Article content copyright by respective authors.