PDA

View Full Version : Sound Function Conflict



wyclef
May 5th, 2004, 11:18 AM
Hi,

How can I change the following so it won't conflict with sounds inserted manually in keyframes. Currently when this function is active, the loop sound works but the other sounds don't play..



soundTrack = new Sound();
soundTrack.attachSound("loop");
soundTrack.setVolume(0);

soundTrack.fadeIn = function(speed) {
var vol = this.getVolume()+speed;
this.setVolume(vol);
display = this.getVolume();
if (this.getVolume()>17) {
this.setVolume(17);
clearInterval(this.interval);
}
};
soundTrack.fadeOut = function(speed) {
var vol = this.getVolume()-speed;
this.setVolume(vol);
display = this.getVolume();
if (this.getVolume()<0) {
this.setVolume(0);
this.stop();
this.playing = false;
clearInterval(this.interval);
}
};
vol_offBTN.onRelease = function() {
vol_offBTN._visible = false;
vol_onBTN._visible = true;
if (!soundTrack.playing) {
soundTrack.start(0, 999);
clearInterval(soundTrack.interval);
soundTrack.interval = setInterval(soundTrack, "fadeIn", 500/12, 1);
soundTrack.playing = true;
}
};
vol_onBTN.onRelease = function() {
vol_offBTN._visible = true;
vol_onBTN._visible = false;
if (soundTrack.playing) {
clearInterval(sndObj.interval);
soundTrack.interval = setInterval(soundTrack, "fadeOut", 200/12, 1);
}
};
soundTrack.start(0, 999);
soundTrack.interval = setInterval(soundTrack, "fadeIn", 500/12, 1);
if (!soundTrack.playing) {
soundTrack.start(0, 999);
clearInterval(soundTrack.interval);
soundTrack.interval = setInterval(soundTrack, "fadeIn", 500/12, 1);
soundTrack.playing = true;
}

wyclef
May 5th, 2004, 12:15 PM
???

Voetsjoeba
May 5th, 2004, 12:22 PM
Why would you want both a song controlled by AS and a song on the timeline ? Seems quite pointless to me.

wyclef
May 5th, 2004, 12:27 PM
I want a song controlled by AS and sound fx on the timeline.....

Voetsjoeba
May 5th, 2004, 12:28 PM
Why not control both with AS ? Sound on the timeline is quite hard to control.

wyclef
May 5th, 2004, 12:38 PM
can you give me an example of how I would accomplish that if I wanted to use 2-3 different sounds? like clicking sounds and swoosh sounds? for buttons and transitions...etc..

Voetsjoeba
May 5th, 2004, 12:54 PM
You just create a different Sound object, and you do anything you want with it as you normally would. This site (http://www.kennybellew.com) may be of help.

wyclef
May 5th, 2004, 12:57 PM
how can i troubleshoot why certain sounds don't play on the timeline?

Voetsjoeba
May 5th, 2004, 01:02 PM
Well, to be honest, I don't know much about timeline sounds, except that they're hard to control. That's why I always use AS to control my sounds ... I wouldn't know why the timeline sound doesn't work.

scotty
May 5th, 2004, 02:18 PM
If you have sounds on the timeline don't they refer their target to the movie?
Then when you use


soundTrack = new Sound();
soundTrack.attachSound("loop");
//
without targetting, it refers again to the movie and replace the sound in the timeline?
try:

_root.createEmptyMovieClip("soundHolder", 1000);
soundTrack = new Sound(soundHolder);
soundTrack.attachSound("loop");

Hope that helps;)

scotty(-:

wyclef
May 5th, 2004, 02:36 PM
Thanks! That solved the problem!

scotty
May 5th, 2004, 02:45 PM
You're welcome;)

wyclef
May 5th, 2004, 03:10 PM
Just to spice things up, would there be a way to have two or three sound objects that rotated out each time you turned the sound off and then on again?

Chuckmul999
May 6th, 2004, 06:53 PM
Why would you want both a song controlled by AS and a song on the timeline ? Seems quite pointless to me.

you sound like you know what your doing I need some serios help I have recently gotten flash Mx 2004 I am good at animation and maby will have a career in it but I also am horrible with actionscript. How the hell do you get a sound file to play at a certian frame by using action script and then how do you stop it please help I am about to go insane

Chuckmul999
May 6th, 2004, 06:59 PM
help please