TwelvestoneFlash

Sound object and volume


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
scudsucker
 
2007-11-20

So, I have been given a flash movie and asked to add sound.

The movie is a long tweened animation, the premise being that the navigation allows teh user to move in either direction along the timeline by dragging a pointer.

I have been asked to get the sound to fade in as the user gets closer to a specific frame. Eg, there is bird imagery in frame 120, and as the user approached frame 120 I need the sound to get louder.

All sounds are in the library.

The problem is that all the sounds are fading in at exactly the same rate- even the "Track.wav" which should not be affected by the onEnterFrame.

In fact, the trace action in the onEnterFrame is apparently showing accurate results for what the volume of each sound object should be; but the reality is that the sounds fade in and out all at the same rate, all apparently following the volume of the last sound in the loop (Projector.wav)

// the most complicated sound object ever! var sdBirds = new Sound(); var sdHeartbeat = new Sound(); var sdMiniBusses = new Sound(); var sdProjector = new Sound(); var sdTrack = new Sound(); // -------------------------------------- var aSounds=[] aSounds[0]={sound:"Birds.wav", frame:120, sdObj:sdBirds, maxVol:40} aSounds[1]={sound:"HeartBeat.wav", frame:45, sdObj:sdHeartbeat, maxVol:40} aSounds[2]={sound:"MiniBusses.wav", frame:55, sdObj:sdMiniBusses, maxVol:40} aSounds[3]={sound:"Projector.wav", frame:155, sdObj:sdProjector, maxVol:40} aSounds[4]={sound:"Track.wav", frame:1, sdObj:sdTrack, maxVol:40} //-------------------------- sdBirds.attachSound(aSounds[0].sound) sdHeartbeat.attachSound(aSounds[1].sound) sdMiniBusses.attachSound(aSounds[2].sound) sdProjector.attachSound(aSounds[3].sound) sdTrack.attachSound(aSounds[4].sound) // ---------------------------------------- for(var i=0; i<aSounds.length-1; i++) { //aSounds[i].setVolume(0) aSounds[i].sdObj.start(0,10000000) } aSounds[4].sdObj.start(0,10000000) // ----------------------------------------

onEnterFrame=function(){ for (var i=0; i<aSounds.length-1; i++) { var d=aSounds[i].maxVol- (Math.sin(Math.abs(((movie_mc._currentframe - aSounds[i].frame) /movie_mc._totalframes)))*100) aSounds[i].sdObj.setVolume((d<0) ? 0 : d)

    trace(aSounds[i].sound + " --> " + aSounds[i].sdObj.getVolume())
}
trace("-------------------------------------------")

}

mystic_juju
 
2007-11-20

its probably that you need to specify targets for your sound objects. if they don't have target objects then they all refer to the same one and a change in one is a change in all. so your

var snd = new Sound()

should be

var snd1 = new Sound(target1); var snd2 = new Sound(target2); and so on

Haven't tested this just now, but have experienced something like this before

scudsucker
 
2007-11-20

Indeed, each sound must have its very own movieclip - problem solved by creating 5 empty movieclips as a targets.

Thanks!

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Sound object and volume