Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Stop Sound On A Specific Sound



I have a main timeline with 3 frames. Each frame has a different movieclip but with the same background music. In frame 2 of the main timeline, I have a movieclip that also has sound. If they hit the next frame button from the
main timeline in while in frame2, the sound continues onto frame 3 of the main timeline. I want to stop the sound from the movieclip in frame 2 but not the background music which continues from 1 through 3.

In frame 2 I have a lightning flash - the wav file has linkage as lightning ----

_root.l = new Sound();
_root.l.attachSound("lightning");
_root.l.setVolume(85);

I start frame 3 of the main timeline with this but it kills the music as well ---
_root.l.setVolume(0);



FlashKit > Flash Help > Flash MX
Posted on: 07-16-2002, 10:56 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

[F8] Stop Specific Sound?
Hey hey.

Let's say i have a frame with stop on it that plays a music loop and a button that leave that frame. Is a there a line of script i can add on the button that stops that specific sound file?

I tried using the stopAllSounds(); but since i have other sounds at the same time it didn't work (the whole file went silent)

Stop Specific Sound (not StopAllSounds)
OK, keep it simple, Asparagus...

I have a band website.
Under Audio/Video, I have a little mp3 player for each song (see code below).
When a user clicks on another menu point (News, Calendar, etc.) I want the player to stop.
But... since I have a background 'ambience' sound I can't just use stopAllSounds.


Code:
// mp3Player class
_soundbuftime = 1;
mp3Player = function (songs, interF, reservedDepth) {
if (songs != undefined && interF != undefined && reservedDepth != undefined && typeof songs == "object" && typeof interF == "object" && typeof reservedDepth == "number") {
this.sound = new Object(new Sound(_root));
this.songs = songs;
this.player = interF;
this.positionDump = 0;
this.songs.index = 0;
this.sound.paused = true;
this.sound.stopped = false;
this.curVolume = 100;
this.player.songInfo.html = true;
this.player.songInfo.condenseWhite = true;
this.player.songInfo.autoSize = "left";
this.safeDepth = reservedDepth-1;
this.player.progressIndicator.offset = this.player.progressIndicator._x;
this.loadHandler = _root.createEmptyMovieClip("LH", ++this.safeDepth);
this.progressHandler = _root.createEmptyMovieClip("PH", ++this.safeDepth);
this.volumeHandler = _root.createEmptyMovieClip("VH", this.safeDepth+3);
this.volumeSlideHandler = _root.createEmptyMovieClip("VSH", ++this.safeDepth+4);
// Start functions ----------------------------------------------------------------------------------------------------
this.setRollOver(1);
this.setControls();
this.setInitialVolume(100);
this.sound.loadSound(this.songs[this.songs.index].url, true);
this.showLoaded();
this.showSongInfo();
this.indicateStatus(1);
this.indicateProgress();
// this.enableDrag();
//
} else {
trace("Invalid parameter(s) specified.");
}
};
mp3Player.prototype.stopProgressIndicator = function() {
delete this.progressHandler.onEnterFrame;
};
mp3Player.prototype.resetProgressIndicator = function() {
delete this.progressHandler.onEnterFrame;
this.player.progressIndicator._x = this.player.progressIndicator.offset;
};
mp3Player.prototype.disableDrag = function() {
delete this.player.progressIndicator.onPress;
delete this.player.progressIndicator.onRelease;
delete this.player.progressIndicator.onReleaseOutside;
};
mp3Player.prototype.indicateStatus = function(stat) {
var tar;
stat>0 ? tar=this.player.playButton : stat+1 ? tar=this.player.pauseButton : tar=this.player.stopButton;
this.player.statusIndicator.easeX(tar._x);
};
mp3Player.prototype.showSongInfo = function() {
var artist = this.songs[this.songs.index].artist;
var title = this.songs[this.songs.index].title;
var output = artist+" "+title;
this.player.songInfo.htmlText = output;
};
mp3Player.prototype.next = function() {
this.sound.stop();
this.songs.index++;
if (this.songs.index>this.songs.length-1) {
this.songs.index = 0;
}
this.showSongInfo();
this.sound = new Object(new Sound(_root));
this.sound.loadSound(this.songs[this.songs.index].url, false);
this.sound.setVolume(this.curVolume);
this.showLoaded();
this.indicateStatus(1);
this.indicateProgress();
};
mp3Player.prototype.setInitialVolume = function(x) {
var ref = this;
var tgt = x/100*this.player.volumeHeight;
var vitgt = this.player.volumeBar._y-tgt;
this.player.volumeNR.text = 100;
this.sound.setVolume(x);
this.curVolume = x;
this.volumeHandler.onEnterFrame = function() {
ref.player.volumeIndicator._y = vitgt-(vitgt-ref.player.volumeIndicator._y)/1.2;
ref.player.volumeBar._height = tgt-(tgt-ref.player.volumeBar._height)/1.2;
if (ref.player.volumeIndicator._y>vitgt-1 && ref.player.volumeIndicator._y<vitgt+1 && ref.player.volumeBar._height>tgt-1 && ref.player.volumeBar._height<tgt+1) {
delete this.onEnterFrame;
}
};
};
mp3Player.prototype.setVolumeDrag = function(x) {
if (x>100) {
x = 100;
}
if (x<0) {
x = 0;
}
var ref = this;
var tgt = x/100*this.player.volumeHeight;
this.sound.setVolume(x);
this.curVolume = x
this.player.volumeNR.text = Math.round(x);
this.volumeHandler.onEnterFrame = function() {
ref.player.volumeBar._height = tgt-(tgt-ref.player.volumeBar._height)/1.2;
if (ref.player.volumeBar._height>tgt-1 && ref.player.volumeBar._height<tgt+1) {
delete this.onEnterFrame;
}
};
};
mp3Player.prototype.dragVolumeSlider = function() {
var ref = this;
var maxH = this.player.volumeHeight;
var vi = this.player.volumeIndicator;
var vb = this.player.volumeBar;
this.volumeSlideHandler.onEnterFrame = function() {
conv = {x:0, y:_root._ymouse};
globalToLocal(conv);
this._y = conv.y;
if (conv.y>=vb._y-maxH-1 && conv.y<=vb._y+1) {
vi._y = conv.y;
ref.setVolumeDrag((vb._y-conv.y)*100/maxH);
}
};
};
mp3Player.prototype.previous = function() {
this.sound.stop();
this.songs.index--;
if (this.songs.index<0) {
this.songs.index = this.songs.length-1;
}
this.showSongInfo();
this.sound = new Object(new Sound(_root));
this.sound.loadSound(this.songs[this.songs.index].url, true);
this.sound.setVolume(this.curVolume);
this.showLoaded();
this.indicateStatus(1);
this.indicateProgress();
};
mp3Player.prototype.indicateProgress = function() {
var ref = this;
this.progressHandler.onEnterFrame = function() {
var played = ref.sound.position;
var total = ref.songs[ref.songs.index].duration;
ref.player.progressIndicator._x = ref.player.progressIndicator.offset+((played/total)*ref.player.loadWidth);
if (played>=total) {
delete this.onEnterFrame;
ref.resetProgressIndicator();
ref.next();
}
};
};
mp3Player.prototype.showLoaded = function() {
var ref = this;
this.loadHandler.onEnterFrame = function() {
var loaded = ref.sound.getBytesLoaded();
var total = ref.songs[ref.songs.index].totalbytes;
ref.player.loadBar._width = (loaded/total)*ref.player.loadWidth;
if (loaded == total) {
delete this.onEnterFrame;
}
};
};
mp3Player.prototype.setRollOver = function(grow) {
if (grow) {
this.player.previousButton.onRollOver = this.player.stopButton.onRollOver=this.player.pauseButton.onRollOver=this.player.playButton.onRollOver=this.player.nextButton.onRollOver=function () {
this.grow();
};
this.player.previousButton.onRollOut = this.player.stopButton.onRollOut=this.player.pauseButton.onRollOut=this.player.playButton.onRollOut=this.player.nextButton.onRollOut=function () {
this.shrink();
};
} else {
this.player.previousButton._alpha = this.player.stopButton._alpha=this.player.pauseButton._alpha=this.player.playButton._alpha=this.player.nextButton._alpha=30;
this.player.previousButton.onRollOver = this.player.stopButton.onRollOver=this.player.pauseButton.onRollOver=this.player.playButton.onRollOver=this.player.nextButton.onRollOver=function () {
this.fadeIn();
};
this.player.previousButton.onRollOut = this.player.stopButton.onRollOut=this.player.pauseButton.onRollOut=this.player.playButton.onRollOut=this.player.nextButton.onRollOut=function () {
this.fadeOut();
};
}
};
mp3Player.prototype.setControls = function() {
var ref = this;
var playB = this.player.playButton;
var prevB = this.player.previousButton;
var stopB = this.player.stopButton;
var nextB = this.player.nextButton;
var pauseB = this.player.pauseButton;
var volIndic = this.player.volumeIndicator;
volIndic.onPress = function() {
ref.dragVolumeSlider();
};
volIndic.onRelease = volIndic.onReleaseOutside=function () {
delete ref.volumeSlideHandler.onEnterFrame;
};
pauseB.onRelease = function() {
if (!ref.sound.stopped) {
ref.sound.stop();
ref.indicateStatus(0);
ref.sound.paused = true;
ref.sound.stopped = false;
ref.sound.pausedPosition = ref.sound.position;
ref.stopProgressIndicator();
}
};
stopB.onRelease = function() {
ref.sound.stop();
ref.indicateStatus(-1);
ref.sound.stopped = true;
ref.sound.paused = false;
ref.sound.pausedPosition = 0;
ref.resetProgressIndicator();
};
playB.onRelease = function() {
if (ref.sound.stopped) {
ref.indicateProgress();
ref.indicateStatus(1);
ref.sound.start(0, 1);
ref.sound.stopped = false;
} else if (ref.sound.paused) {
ref.indicateProgress();
ref.indicateStatus(1);
ref.sound.start(ref.sound.pausedPosition/1000, 1);
ref.sound.paused = false;
}
};
nextB.onRelease = function() {
ref.resetProgressIndicator();
ref.next();
};
prevB.onRelease = function() {
ref.resetProgressIndicator();
ref.previous();
};
};
mp3Player.prototype.enableDrag = function() {
var ref = this;
this.player.progressIndicator.onPress = function() {
ref.sound.stop();
ref.stopProgressIndicator();
ref.indicateStatus(0);
ref.sound.paused = true;
ref.sound.stopped = false;
total = ref.songs[ref.songs.index].duration;
this.onEnterFrame = function() {
conv = {x:_root._xmouse};
globalToLocal(conv);
this._x = conv.x;
if (conv.x<ref.player.loadBar._x) {
this._x = ref.player.loadBar._x;
}
if (conv.x>ref.player.loadBar._x+ref.player.loadWidth) {
this._x = ref.player.loadBar._x+ref.player.loadWidth;
}
var percent = ((this._x-ref.player.loadBar._x)/ref.player.loadWidth)*100;
this.newPosition = (percent*total)/100;
};
};
this.player.progressIndicator.onRelease = this.player.progressIndicator.onReleaseOutside=function () {
if (this.newPosition>=ref.songs[ref.songs.index].duration) {
this.newPosition = ref.songs[ref.songs.index].duration-1;
}
delete this.onEnterFrame;
ref.sound.start(ref.player.progressIndicator.newPosition/1000, 1);
ref.sound.paused = false;
ref.sound.stopped = false;
ref.indicateStatus(1);
ref.indicateProgress();
};
};
//prototypes
MovieClip.prototype.fadeIn = function() {
this.onEnterFrame = function() {
this._alpha += 2;
this._alpha>=100 ? delete this.onEnterFrame : null;
};
};
MovieClip.prototype.fadeOut = function() {
this.onEnterFrame = function() {
this._alpha -= 2;
this._alpha<=30 ? delete this.onEnterFrame : null;
};
};
MovieClip.prototype.grow = function() {
var t = 140;
this.onEnterFrame = function() {
this._xscale = this._yscale=t-(t-this._xscale)/1.5;
if (this._xscale>t-1 && this._xscale<t+1) {
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.shrink = function() {
var t = 100;
this.onEnterFrame = function() {
this._xscale = this._yscale=t-(t-this._xscale)/1.5;
if (this._xscale>t-1 && this._xscale<t+1) {
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.easeX = function(t) {
this.onEnterFrame = function() {
this._x = t-(t-this._x)/1.5;
if (this._x>t-1 && this._x<t+1) {
delete this.onEnterFrame;
}
};
};
// creation of mp3Player class instance and junk
songsArray = new Array();
playerInterface = new Object();
playerInterface.playButton = this.playButton;
playerInterface.stopButton = this.stopButton;
playerInterface.pauseButton = this.pauseButton;
playerInterface.previousButton = this.previousButton;
playerInterface.nextButton = this.nextButton;
playerInterface.loadBar = this.loadbar;
playerInterface.loadWidth = 333;
playerInterface.progressIndicator = this.proIndic;
playerInterface.statusIndicator = this.statusIndic;
playerInterface.songInfo = this.songInfo;
playerInterface.volumeBar = this.volumeBar;
playerInterface.volumeNR = this.volumeNR;
playerInterface.volumeIndicator = this.volumeIndic;
playerInterface.volumeHeight = 100;
//---------------------------------------------------
XMLRetrieve = new XML();
XMLRetrieve.ignoreWhite = true;
XMLRetrieve.load("mp3/track01.xml");
XMLRetrieve.onLoad = function() {
for (var j = 0; j<this.firstChild.childNodes.length; j++) {
/* Handle duration and convert to milliseconds */
dur = this.firstChild.childNodes[j].attributes.duration;
dblPnt = dur.indexOf(":");
mins = Number(dur.substr(0, dblPnt));
sec = Number(dur.substr(dblPnt+1, dur.length));
ms = ((mins*60)+sec)*1000;
/* Handle filesize and convert to bytes */
songsArray.push({title:this.firstChild.childNodes[j].attributes.title, artist:this.firstChild.childNodes[j].attributes.artist, url:this.firstChild.childNodes[j].firstChild.nodeValue, duration:ms, totalbytes:Number(this.firstChild.childNodes[j].attributes.filesize)});
}
player = new mp3Player(songsArray, playerInterface, 1);
};

Stop Specific Sound (not StopAllSounds)
OK, keep it simple, Asparagus...

I have a band website.
Under Audio/Video, I have a little mp3 player for each song (see code below).
When a user clicks on another menu point (News, Calendar, etc.) I want the player to stop.
But... since I have a background 'ambience' sound I can't just use stopAllSounds.


Code:
// mp3Player class
_soundbuftime = 1;
mp3Player = function (songs, interF, reservedDepth) {
if (songs != undefined && interF != undefined && reservedDepth != undefined && typeof songs == "object" && typeof interF == "object" && typeof reservedDepth == "number") {
this.sound = new Object(new Sound(_root));
this.songs = songs;
this.player = interF;
this.positionDump = 0;
this.songs.index = 0;
this.sound.paused = true;
this.sound.stopped = false;
this.curVolume = 100;
this.player.songInfo.html = true;
this.player.songInfo.condenseWhite = true;
this.player.songInfo.autoSize = "left";
this.safeDepth = reservedDepth-1;
this.player.progressIndicator.offset = this.player.progressIndicator._x;
this.loadHandler = _root.createEmptyMovieClip("LH", ++this.safeDepth);
this.progressHandler = _root.createEmptyMovieClip("PH", ++this.safeDepth);
this.volumeHandler = _root.createEmptyMovieClip("VH", this.safeDepth+3);
this.volumeSlideHandler = _root.createEmptyMovieClip("VSH", ++this.safeDepth+4);
// Start functions ----------------------------------------------------------------------------------------------------
this.setRollOver(1);
this.setControls();
this.setInitialVolume(100);
this.sound.loadSound(this.songs[this.songs.index].url, true);
this.showLoaded();
this.showSongInfo();
this.indicateStatus(1);
this.indicateProgress();
// this.enableDrag();
//
} else {
trace("Invalid parameter(s) specified.");
}
};
mp3Player.prototype.stopProgressIndicator = function() {
delete this.progressHandler.onEnterFrame;
};
mp3Player.prototype.resetProgressIndicator = function() {
delete this.progressHandler.onEnterFrame;
this.player.progressIndicator._x = this.player.progressIndicator.offset;
};
mp3Player.prototype.disableDrag = function() {
delete this.player.progressIndicator.onPress;
delete this.player.progressIndicator.onRelease;
delete this.player.progressIndicator.onReleaseOutside;
};
mp3Player.prototype.indicateStatus = function(stat) {
var tar;
stat>0 ? tar=this.player.playButton : stat+1 ? tar=this.player.pauseButton : tar=this.player.stopButton;
this.player.statusIndicator.easeX(tar._x);
};
mp3Player.prototype.showSongInfo = function() {
var artist = this.songs[this.songs.index].artist;
var title = this.songs[this.songs.index].title;
var output = artist+" "+title;
this.player.songInfo.htmlText = output;
};
mp3Player.prototype.next = function() {
this.sound.stop();
this.songs.index++;
if (this.songs.index>this.songs.length-1) {
this.songs.index = 0;
}
this.showSongInfo();
this.sound = new Object(new Sound(_root));
this.sound.loadSound(this.songs[this.songs.index].url, false);
this.sound.setVolume(this.curVolume);
this.showLoaded();
this.indicateStatus(1);
this.indicateProgress();
};

mp3Player.prototype.previous = function() {
this.sound.stop();
this.songs.index--;
if (this.songs.index<0) {
this.songs.index = this.songs.length-1;
}
this.showSongInfo();
this.sound = new Object(new Sound(_root));
this.sound.loadSound(this.songs[this.songs.index].url, true);
this.sound.setVolume(this.curVolume);
this.showLoaded();
this.indicateStatus(1);
this.indicateProgress();
};
mp3Player.prototype.indicateProgress = function() {
var ref = this;
this.progressHandler.onEnterFrame = function() {
var played = ref.sound.position;
var total = ref.songs[ref.songs.index].duration;
ref.player.progressIndicator._x = ref.player.progressIndicator.offset+((played/total)*ref.player.loadWidth);
if (played>=total) {
delete this.onEnterFrame;
ref.resetProgressIndicator();
ref.next();
}
};
};
mp3Player.prototype.showLoaded = function() {
var ref = this;
this.loadHandler.onEnterFrame = function() {
var loaded = ref.sound.getBytesLoaded();
var total = ref.songs[ref.songs.index].totalbytes;
ref.player.loadBar._width = (loaded/total)*ref.player.loadWidth;
if (loaded == total) {
delete this.onEnterFrame;
}
};
};
mp3Player.prototype.setRollOver = function(grow) {
if (grow) {
this.player.previousButton.onRollOver = this.player.stopButton.onRollOver=this.player.pauseButton.onRollOver=this.player.playButton.onRollOver=this.player.nextButton.onRollOver=function () {
this.grow();
};
this.player.previousButton.onRollOut = this.player.stopButton.onRollOut=this.player.pauseButton.onRollOut=this.player.playButton.onRollOut=this.player.nextButton.onRollOut=function () {
this.shrink();
};
} else {
this.player.previousButton._alpha = this.player.stopButton._alpha=this.player.pauseButton._alpha=this.player.playButton._alpha=this.player.nextButton._alpha=30;
this.player.previousButton.onRollOver = this.player.stopButton.onRollOver=this.player.pauseButton.onRollOver=this.player.playButton.onRollOver=this.player.nextButton.onRollOver=function () {
this.fadeIn();
};
this.player.previousButton.onRollOut = this.player.stopButton.onRollOut=this.player.pauseButton.onRollOut=this.player.playButton.onRollOut=this.player.nextButton.onRollOut=function () {
this.fadeOut();
};
}
};
mp3Player.prototype.setControls = function() {
var ref = this;
var playB = this.player.playButton;
var prevB = this.player.previousButton;
var stopB = this.player.stopButton;
var nextB = this.player.nextButton;
var pauseB = this.player.pauseButton;
var volIndic = this.player.volumeIndicator;
volIndic.onPress = function() {
ref.dragVolumeSlider();
};
volIndic.onRelease = volIndic.onReleaseOutside=function () {
delete ref.volumeSlideHandler.onEnterFrame;
};
pauseB.onRelease = function() {
if (!ref.sound.stopped) {
ref.sound.stop();
ref.indicateStatus(0);
ref.sound.paused = true;
ref.sound.stopped = false;
ref.sound.pausedPosition = ref.sound.position;
ref.stopProgressIndicator();
}
};
stopB.onRelease = function() {
ref.sound.stop();
ref.indicateStatus(-1);
ref.sound.stopped = true;
ref.sound.paused = false;
ref.sound.pausedPosition = 0;
ref.resetProgressIndicator();
};
playB.onRelease = function() {
if (ref.sound.stopped) {
ref.indicateProgress();
ref.indicateStatus(1);
ref.sound.start(0, 1);
ref.sound.stopped = false;
} else if (ref.sound.paused) {
ref.indicateProgress();
ref.indicateStatus(1);
ref.sound.start(ref.sound.pausedPosition/1000, 1);
ref.sound.paused = false;
}
};
nextB.onRelease = function() {
ref.resetProgressIndicator();
ref.next();
};
prevB.onRelease = function() {
ref.resetProgressIndicator();
ref.previous();
};
};
mp3Player.prototype.enableDrag = function() {
var ref = this;
this.player.progressIndicator.onPress = function() {
ref.sound.stop();
ref.stopProgressIndicator();
ref.indicateStatus(0);
ref.sound.paused = true;
ref.sound.stopped = false;
total = ref.songs[ref.songs.index].duration;
this.onEnterFrame = function() {
conv = {x:_root._xmouse};
globalToLocal(conv);
this._x = conv.x;
if (conv.x<ref.player.loadBar._x) {
this._x = ref.player.loadBar._x;
}
if (conv.x>ref.player.loadBar._x+ref.player.loadWidth) {
this._x = ref.player.loadBar._x+ref.player.loadWidth;
}
var percent = ((this._x-ref.player.loadBar._x)/ref.player.loadWidth)*100;
this.newPosition = (percent*total)/100;
};
};
this.player.progressIndicator.onRelease = this.player.progressIndicator.onReleaseOutside=function () {
if (this.newPosition>=ref.songs[ref.songs.index].duration) {
this.newPosition = ref.songs[ref.songs.index].duration-1;
}
delete this.onEnterFrame;
ref.sound.start(ref.player.progressIndicator.newPosition/1000, 1);
ref.sound.paused = false;
ref.sound.stopped = false;
ref.indicateStatus(1);
ref.indicateProgress();
};
};
// creation of mp3Player class instance and junk
songsArray = new Array();
playerInterface = new Object();
playerInterface.playButton = this.playButton;
playerInterface.stopButton = this.stopButton;
playerInterface.pauseButton = this.pauseButton;
playerInterface.previousButton = this.previousButton;
playerInterface.nextButton = this.nextButton;
playerInterface.loadBar = this.loadbar;
playerInterface.loadWidth = 333;
playerInterface.progressIndicator = this.proIndic;
playerInterface.statusIndicator = this.statusIndic;
playerInterface.songInfo = this.songInfo;
playerInterface.volumeBar = this.volumeBar;
playerInterface.volumeNR = this.volumeNR;
playerInterface.volumeIndicator = this.volumeIndic;
playerInterface.volumeHeight = 100;
//---------------------------------------------------
XMLRetrieve = new XML();
XMLRetrieve.ignoreWhite = true;
XMLRetrieve.load("mp3/track01.xml");
XMLRetrieve.onLoad = function() {
for (var j = 0; j<this.firstChild.childNodes.length; j++) {
/* Handle duration and convert to milliseconds */
dur = this.firstChild.childNodes[j].attributes.duration;
dblPnt = dur.indexOf(":");
mins = Number(dur.substr(0, dblPnt));
sec = Number(dur.substr(dblPnt+1, dur.length));
ms = ((mins*60)+sec)*1000;
/* Handle filesize and convert to bytes */
songsArray.push({title:this.firstChild.childNodes[j].attributes.title, artist:this.firstChild.childNodes[j].attributes.artist, url:this.firstChild.childNodes[j].firstChild.nodeValue, duration:ms, totalbytes:Number(this.firstChild.childNodes[j].attributes.filesize)});
}
player = new mp3Player(songsArray, playerInterface, 1);
};

How Do I Stop A Specific Sound Playing?
I'm sure the answer must be very simple but I'm having difficult figuring it out. I have two sounds, 'cranes' and 'drumroll'. I have two buttons, one which triggers cranes and one which triggers drumroll. So far so good, everything works.

However, I want to make it so that if the drumroll is still playing when the cranes sound starts playing, the drumroll stops. Likewise I want the cranes sound to stop playing when the drumroll starts.

I've pasted the code below; would be much obliged for any help...


Code:
//SET UP SOUNDS
var reqCranes:URLRequest = new URLRequest("cranes.mp3");
var sCranes:Sound = new Sound(reqCranes);
var reqDrumroll:URLRequest = new URLRequest("drumroll.mp3");
var sDrumroll:Sound = new Sound(reqDrumroll);

//CLICKABLE AREA INSTRUCTIONS
button1.addEventListener(MouseEvent.CLICK, cranes);
button2.addEventListener(MouseEvent.CLICK, drumroll);

//LAUNCH SOUNDS
function cranes(event:MouseEvent):void {
var channelCranes:SoundChannel = sCranes.play();
//Code I want here: stop the drumroll sound
}
function drumroll(event:MouseEvent):void {
var channelDrumroll:SoundChannel = sDrumroll.play();
//Code I want here: stop the cranes sound
}

How To Stop Only Specific Sound In Library
I want to stop with button specific sound which is playing in the background.

The code for playing audio is:

Code:

this.createEmptyMovieClip("mcSoundHolder", this.getNextHighestDepth());
var s:Sound = new Sound(mcSoundHolder);
s.attachSound("type");
s.start();


The problem is, that if I use the code below, all audio stops playing:

Code:

var soundType:Sound = new Sound();
soundType.attachSound("type");

this.btn1.onRelease = function() {
     soundType.stop();
}

If I use the code below, it doesn't stop the audio:

Code:

this.createEmptyMovieClip("mcSoundHolder", this.getNextHighestDepth());
var soundType:Sound = new Sound(mcSoundHolder);
soundType.attachSound("type");

this.btn1.onRelease = function() {
     soundType.stop();
}


Please, help :(

Stop Specific Sound File In Flash
Hi guys,

I am using three different sound in my flash presentation.

1. Sound1.wav
2. Sound2.wav
3. Sound3.wav

I am using these sound file Know i wanted to stop a "sound2.wav" and wanted to start sound3.wav after stopping sound2.wav.

Any body now how to s specific sound file in flash with file name.

I try so many different ways but i couldn't succeed.
Plz help me

Thanks
Kaleem.

Attach Sound, Play Sound & Stop Sound.
Hey there,

I was wondering if any of you could help me please.

I want to play a song which I have named "rundmc" The file extension is ".mp3"

I want a button to play this mp3 which I read you need to attach that sound, then play it and I want to a button to stop that sound, or preferably the play button to change into a stop button.

I've read the help files, but none of it works and I've changed the linkage for the mp3 to export for action script, but nothing works!!!

Please help,

NK.

.stop() For Sound Object Stopping Embedded Video Sound
I have a problem where the stop funtion for a sound object is stopping the audio in an embedded video. Has anyone ever encountered this? Ihave poured over my code and there is no cross-linked intance names, so I do not have a clue what is happening.

Stop Sound File Early (using Sound Object)
I know I can use the play() method of the Sound object to offset the beginning of a sound. Ex:

mySound.play(2000) - plays the sound beginning at 2 seconds

Is there a way to get a sound to stop early? For example, if it is a 20-second sound, can I get it to stop at 18 seconds? Thanks!

On Press Play Sound On Release Stop Sound
I have a button that is inside a movie clip 'forward'.
When you press the button it plays another movie clip 'time' forwards

on (press) {
forward = "1";
}
on (release, rollOut, dragOut) {
forward = "0";
}

on the button and:

if (forward eq "1") {
tellTarget ("/time") {
nextFrame();
}
}

on the first frame of the 'forward' movie


I would like sound to happen when you press the button and stop when you realease the button

but I not sure how any help would be gratefully excepted

Rollover W/sound , Stop Sound On Rollout
HI,

I've got rollovers w/sound, that are close to each other. When i roll over them, they ALL play...How do I stop sound on rollout WITHOUT stopping my Background sounds?

Help Appreciated, Thx

Rollover Sound On - Rolver Sound Stop
I am new to Flash but would like a little more control over a button sound than I currently understand. I would like a sound to play on rollover of a button but as soon as the mouse is outside that button, I would like the sound to stop. Is there an easy way to achieve this?

Thanks

Need Start And Stop Sound Help ON AND OFF BUTTONS FOR SOUND PLZ
ok I have a Flash site iM making with BG music but I need a START and STOP Button and a Next and Prev button for the music so PLEASE help me out with this is u can I need FULL instructions

Sound.getbytesload And Sound.stop() MXPRO2004
I've figured out a workaround for this, but was just posting to see if anyone has a better way to do this.
What I want to create is a streaming player that shows a bar of how much of the sound is loaded and an indicator on the bar of where the sound is currently at while playing. I would also like the sound to start loading as soon as the movie is loaded, but not start playing until the user presses the play button.
The problem I run into is if I stop the sound, the loading of the sound stops too. So, the only way to have the sound load is to also play it. The workaround I'm using is as follows:

When the sound first starts loading, I set the soundvolume to 0. If the user presses the play button, I begin playing the sound from the beginning. If the user presses the pause button, I record the duration of the sound into a variable, but instead of using mySound.stop(), I turn the volume to 0 and let the sound continue to play. If the user then unpauses the sound I start play from the duration number where it was last paused.

I'd like to be able to use sound.stop() on this, but I don't think it's going to work. Any ideas?

HELP Sound Object Stop Kills Flv Sound Too
code:
if (!firstTime) {
_root.introMusic = new Sound();
_root.introMusic.attachSound("music");
_root.introMusic.setVolume(50);
_root.introMusic.start(0, 1);
firstTime = true;
}

music_btn.onRelease = function() {
if (!rockNow) {
_root.introMusic.setVolume(0);
this.gotoAndStop(2);
rockNow = true;
} else {
_root.introMusic.setVolume(50);
this.gotoAndStop(1);
rockNow = false;
}
};
stop();


This script for my "music on/off" btn kills ALL audio and not just the sounds object audio. It also pauses FLV playback (I'm using the FLVplayback component). Any insite?

I've tried modifying the above AS not using the "_root." to target the obj and also stop() and start() on the obj instead of just volume control. HELP!!!

Thanks,
1M.

Play Sound/stop Sound Button
i want to make a single button to play a sound, and if pressed again, stop the sound. and if pressed again, play the sound, and so on...
i know it has to be made with a boolean variable, true/false, but i just can't figure out how.
any help?
thank you very much.

Sound.stop Is OK, Sound.start ?
I create a button that stop sound, but i do not know how to create a button that will start to play that sound again.
I try with sound.start but does not work, pleas help?

PLAY Sound And STOP Sound
I have no clue how to play and stop sound. I tried everything but I guess I am doing it wrong!
basically...... the name of the clip i want to play is
sound1

i have a little play button and a little stop button
i need the code so that it will play sound1 when clicked on
and the stop button i just put stop all sounds so i guess that should take care of it..but if that is wrong then please let me know, lol
thanks

xox marqi

Sound Stop And Sound Start
Hi There.

I have the follwoing problem. I have this play/pause button that toggles. This works. When clicking it the movie freezes and when clicking it again it runs. I have now added sound to the timeline, and what I want is that when clicking the pause button the movie freezes but also the sound freezes. Clicking the pause button again should start the movie and the sound again.

I have written the follwoing actionscript to the button:


Code:
isPaused = true;
allSounds=new Sound();

this.movieClip.play_btn.onRelease = function() {
isPaused = !isPaused;
movieClip.gotoAndStop(isPaused ? 1 : 5);
stop();
_root.allSounds.stop();
if (isPaused==true) {
play();
trace("We are rolling");
trace("and this is frame "+_root._currentFrame);
_root.allSounds.start(0,99);
}
}
It does half of it good. When I now click the button, the movies freezes and the music stops. When I click again the movie starts again, except that I do not hear any sound anymore. I am sure it is just some simple error, but any tips would be welcome!

Thnx!

How To Make A Sound Stop Only That Sound...
i think my problem is simple but i just am not getting a certain code. ok i have a radio in my flash mx vid. when i click it once. it plays music. when i click it again, it stops it all sounds. how do i make it just stop THAT sound?


{Radio} <---- movie clip

Sound Object - Specifying Only Certain Sound To Stop
Hi everyone. I'll try to make this as brief as possible. I am creating a flash project which contains video on a few pages. The project also contains background music which loops contiuously.

The goal is to have the background music stop whenever the user is on a page containing video and for the music to play again when the user leaves said page.

The script I created works to stop the music, but it also stops the audio contained within the video and causes the video player (by proxxus) to lock up.

The solution is probably a simple one, but I'm having difficulty figuring it out.
If anybody can see where I've gone wrong, your help would be greatly appreciated. Here's the setup:

Library:
music.wav - linkage = "myMusic01"

Main Timeline:

Code:
//-- create a variable to determine if the current movie contains video
var currMovie:String = "notVideo";
//-- start playing sound object
myMusicMc.myMusic.start(0, 999);
myMusicMc (residing on main timeline)
frame 1

Code:
//-- set up sound object
myMusic=new Sound();
myMusic.attachSound("myMusic01");
frame 2

Code:
//-- check the variable "currMovie"
if (_root.currMovie == "Video") {
_root.myMusicMc.myMusic.stop();
} else {
_root.myMusicMc.myMusic.play();
}
frame 3

Code:
//-- create a loop to continuously check the variable
gotoAndPlay(2);
on the actions layer of the movie clip containing my navigation controls
snippet of the callback used

Code:
videoLink_mc.onRelease = function() {
_parent.prodDetail_mc.gotoAndPlay("video");
_root.currMovie="Video";
}
on all the other buttons currMovie is set to "notVideo"

Stop Sound To Start Another Sound
I have a movie -a read aloud ebook for kids-with a main soundfile, and buttons with soundfiles (definition of the word in the text). I need to be able to click on the word definition button, stop the main soundfile, listen to the word definition button soundfile, then return to the main soundfile. Everything in the movie works perfectly except that with the code below (on each button), on rollOver ALL sounds are stopped, and I can't work out how else to do it. Can anyone show me how to do this without the onRollover please?

on (rollOver) {
stopAllSounds();
}
on (press) {
_root.play();
}
on (release) {
_root.stop();
_root.btnStopPlay.attachMovie("mcButtonPlay", "btnPlay", 1);
}

How To Make A Sound Stop Only That Sound...
i think my problem is simple but i just am not getting a certain code. ok i have a radio in my flash mx vid. when i click it once. it plays music. when i click it again, it stops it all sounds. how do i make it just stop THAT sound?


{Radio} <---- movie clip

Specific Sound
hi!
having some trouble...
need to stop a specific sound.
Does anyone know how?

Thanks in advance

Looking For Specific Sound...Please Help.
Hello,

I am working on v2 of my design site

Check it out:

night fall multimedia v1.49

I need a lightning type sound for when you put your mouse over the navbar items and the electricity appears.

Anybody got anywhere where I could find this sound? (I tried flashkit already)

Thanks,

-Nick

[F8] Fade Out Specific Sound
Hi all,

I am trying to figure a way to fade out only my background music instead off fading all sounds out. I found some code that works well in fading out all sounds:


Code:
// initiate sound
music = new Sound();
music.attachSound("sound879");
music.start(0, 999999);
// set the volume of the sound to zero
music.setVolume(100);
// set a variable named 'vol'
vol = 100;
// set another variable named 'fade', putting a setInterval function in it
fade = setInterval(fadeIn, 0);
// set the initial fade in function
function fadeIn() {
// fade the sound in with an increment of 3 in the variable 'vol'
vol += 3;
music.setVolume(vol);
// put an if condition to restrict the increment in volume after it reaches to 100
if (vol>=100) {
clearInterval(fade);
// create the 'step' variable
step = 1;
// create the 'fade' variable
fade = 0;
}
}
// create the fade in and out function
// function executed on onEnterFrame
_root.onEnterFrame = function() {
// set fade out
if (fade == 1) {
vol = vol-step;
if (vol<0) {
vol = 0;
}
music.setVolume(vol);
// set fade in
} else {
vol = vol+step;
if (vol>100) {
vol = 100;
}
music.setVolume(vol);
}
};


and this works great to fade out all sounds but I have other sounds that occur say if you roll over a btn that I would like to keep active.

This code is the trigger that I use to fade in and out the sound :


Code:
on (release)
{
(_root.fade=!_root.fade) ? 0 : 1;
}


I have tried to load the sound on level1 but that did not work. Do you have any ideas how I can just fade out "sound876" alone while keep all other sounds active?

Any help would be greatly appreciated.

Thanks
Trinidad :]

Stopping A Specific Sound
Hi, how can I stop a specific sound when I press a button? For example I have a menu with a soundtrack, and when you click a button it takes you to the other scene (or whatever) and stops all sounds. But the problem is that in the scene/frame that it takes you there is a soundtrack that won't play. Can anyone help me here? The code I have on the button is:


Code:
on (release) {
gotoAndPlay("some scene", 1);
stopAllSounds();
}
Thanks in advance

Turn Off Specific Sound
Hi,

I have the following actionscript to turn off all the sound , but I only want to turn off one mp3 and leave the other sounds playing:

onClipEvent (load) {
_root.soundstatus="off";


}

How can I modify this?

Cheers

Loading Sound On A Specific Frame
Hi,i have used this code in order to play a sound within my site:

mySound = new Sound();
mySound.attachSound("end");

The problem is, flash loads the sound at the start of the whole movie instead of waiting until the frame in which this code is on and loading it. Meaning instead of having a nice loading page its a blank page for about 3 minutes.

Please help!
thank you
Joe

Turn Off Sound For A Specific Wav File
Hello - I have a button that loads a movie that contains sound. I'd like when this button gets pressed that it stop a specific .wav file that's loaded in the background of the main movie (not the one being loaded). I'm not sure if I have to do this by specifying a specific layer, or attach some kind of linkage tag to the .wav. Any idea's or suggestions are appreciated.

Thanks.

Attached Sound At Specific Point
I was wondering if there was a way to tell a sound that has been attached from the library to start playing at a specific point?


my code for placing the sound is similar to this:

Code:
this.createEmptyMovieClip("soundClip",getNextHighestDepth());
mySound = new Sound(soundClip);
mySound.attachSound("sound");
mySound.setVolume(50);

mySound.start(0,9999);

Puase Sound At Specific Position
I have read up on how to puase a sound file and store its position so i can resume it from the same spot. BUT what i can't understand is if i know what millisecond i wanted to puase the file, how do i do that?

Or is there a code, if i were to splice the large sound file i have already, it would wait until the file has finished before allowing anybody to resume play. I hope this is somewhat clear! THANK YOU!

Pause/play Sound At Specific Time
Hi,

I have one problem regarding sound clip. I have one sound clip... now in movie when you click on pause sound must stop at specific point when it reaches... and when you click play the sound must start originally when it paused. I want action script for this.

Thanking you,

Bhavin kalaria.

I May Have Posted In The Wrong Forum: Sound And A Specific PC
Hi,
http://www.flashkit.com/board/showth...hreadid=510686

Describes a problem I am having with a single machine that will neither detect nor play an MP3 loaded dynamically. Any help on where to start looking is massively appreciated.

BTW, all the files are in the correct place and the site works on every other computer/browser combination I have tried.

Thanks,

Gaius

[F8] Fading Out Specific Sound While Keeping Others Active
Hi all,

I am trying to figure a way to fade out only my background music instead off fading all sounds out. I found some code that works well in fading out all sounds:


Code:
// initiate sound
music = new Sound();
music.attachSound("sound879");
music.start(0, 999999);
// set the volume of the sound to zero
music.setVolume(100);
// set a variable named 'vol'
vol = 100;
// set another variable named 'fade', putting a setInterval function in it
fade = setInterval(fadeIn, 0);
// set the initial fade in function
function fadeIn() {
// fade the sound in with an increment of 3 in the variable 'vol'
vol += 3;
music.setVolume(vol);
// put an if condition to restrict the increment in volume after it reaches to 100
if (vol>=100) {
clearInterval(fade);
// create the 'step' variable
step = 1;
// create the 'fade' variable
fade = 0;
}
}
// create the fade in and out function
// function executed on onEnterFrame
_root.onEnterFrame = function() {
// set fade out
if (fade == 1) {
vol = vol-step;
if (vol<0) {
vol = 0;
}
music.setVolume(vol);
// set fade in
} else {
vol = vol+step;
if (vol>100) {
vol = 100;
}
music.setVolume(vol);
}
};
and this works great to fade out all sounds but I have other sounds that occur say if you roll over a btn that I would like to keep active.

This code is the trigger that I use to fade in and out the sound :


Code:
on (release)
{
(_root.fade=!_root.fade) ? 0 : 1;
}
I have tried to load the sound on level1 but that did not work. Do you have any ideas how I can just fade out "sound879" alone while keep all other sounds active?

Any help would be greatly appreciated.

Thanks
Trinidad :]

Setting Volume For Specific Sound Objects
Hello,

I ran into an odd behavour. I put together a quick demo in flash that uses external FLV and imported WAV. Instead of making an MC and dragging the audio onto the frame, I decided to build an object in Action Script (using linkage from the library). Since the volumes in the FLVs and the WAVs vary, it's been useful to be able to adjust the volume as needed (without giving the user control over it).

Here is the code I used for the FLV:

Code:
on (complete) {
var soundByte:Sound = new Sound();
soundByte.attachSound("wav1");
soundByte.setVolume(20);
soundByte.start();
}
The odd thing is that when it sets the volume for the object, it sets the voume for everything. All other FLVs are affected by the code. Am I doing something wrong? How do affect just the object's volume and not all of it? Please advise. Thank you.

Linnium

Setting Volume For Specific Sound Files
hi there.

I have 2 narration sound files (set as 'stream') on my timeline running at the same time in scene 2.
1 is narration in Welsh, 1 is narration in English.

in my first scene I have buttons to select either the Welsh or English narration.

how would i code it so that when the english button has been clicked then only the english narration sounds in scene 2 (with the welsh narration at volume= 0)

please if anyone could help me out.

thanks,
-Will

Fade Sound Out At Specific Frame In Timeline
greetings,

I've searched and read a few posts for fading sounds without the use of buttons - but the answer just fell short (the person figured out what to do, so the thread ended)

Frame 1 on main timeline:
bouncing = new Sound();
bouncing.attachSound("bouncing");
bouncing.start(0, 1);

I want to be able to fade this sound out on a specifc frame to accomodate different processor speeds and such e.g on my G5 the animation ends before the sound. on my G4 the sound ends before the animation.

Might anyone have an idea on how to accomplish this?
Thanks for the help!

Attach Sound At Specific Frame Of Movieclip?
Is there any way to attach a sound at a specific frame of a movieclip?  I'm having trouble finding any documentation that might indicate this can be done.

In brief, I have this simulation that responds to a keypad; different animations are triggered based on the button pressed.  Some of the .flv's have audio attached, but when audio's attached to the .flv, it's pausing when it goes back to loop.  So, I figured I'd try removing just the part of the sound that needs to loop & attach it dynamically.  Trouble is, I can't figure out how to attach it to frame 37 of movieclip1, or how to tell it to start once it hits frame 37.

Any ideas?

Thanks!

tigerjade

"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." --  Martin Golding




Fading Out The Specific Sound Without Effecting Other Sounds
Hi!

Is it possible to fade out only specific sound which is added by AS and not effecting other sounds which are added in timeline? My problem is, when the 1st sound gets faded (lowering the volume to 0), the other sounds that should play after 1st sound aren't hearable because setVolume is at 0.

One solution is to attach all sounds through AS on it's own MovieClip, but I'm wondering is there any other way?

Here's my code:

Code:

// Declaring variables
this.createEmptyMovieClip("soundHolder", 100);//this.getNextHighestDepth());
var sound:Sound = new Sound(soundHolder);
sound.attachSound("wind");
var fadeIntervalId:Number;
var volval:Number = 100;
//
// This is fading audio function
function fadeOut() {
   clearInterval(fadeIntervalId);
   var diff:Number = Math.round(volval/20);
   //the step of decrease/increase
   fadeIntervalId = setInterval(function () {
      if (sound.getVolume()>0) {
         sound.setVolume(sound.getVolume()-diff);
      } else {
         clearInterval(fadeIntervalId);
      }
   }, 10);
}
//
// This is preloader function
this.onEnterFrame = function() {
   if (getBytesLoaded()<getBytesTotal()) {
      sound.start();
   } else if (getBytesLoaded() == getBytesTotal()) {
      fadeOut();      
      delete this.onEnterFrame;
      
   }
};

Thanks in advanced,

bye Mario :D

How To Stop MC At Same Time As Sound Stop?
Hi and thanx for u trieing to help me.
I have used this code to play a sound from the library.

with (song_link) {
sound1 = new Sound(song_link);
sound1.attachSound("inga");
sound1.setVolume(100);
sound1.start(0, 0);
}

and when the sound stops i would like to stop a MC that loops.

if there is any way to have an if command in the MC that waits for a variable to be sended and then stops.

or to set some kind of countdown when u start to play the sound that tells the MC to stop.

i would be very glad if u could help me!

Stop Movie - Don't Stop Sound
Hello,
I'm making a intro for somebody's site. The intro plays a loop. At the last frame I made a stop script. But I want to the muis (a loop) to play on and on. So the music won't stop when the movie stops.
Can somebody help me?
Tnx & greetz, Big_Boss_Man

If I Stop The Sound I Want To Play It From Where Is Stop :)
hi all

i want a button if i cilck on it the sound will stop and another button if i click on it the sound will continue from where it is stoped is it possible in flash or not

and the sound where is the best place i place it ( movie clip - main frame - action ????


thanks

if any one can give me an open file to be clear or the code

Cannot Stop A Sound
I am having trouble with sounds. I thought that the way to do it was to add the sound to a MC in frame 1, put it on the stage, and give it an instance name (sound34) and on a button to stop it put

on (release) {
sound34.stop();
}


But it doesn't work? Am I missing something important?

Thanks
Emily

Stop ALL Sound
how do I stop all the sound in a movie. I use the stopallsound action but is don't work.

Stop ONE Sound
Hi.

I'm trying to get ONE particular sound to stop playing when a skip inro button is released. I do not want to stop all sounds.
I have placed the sound, on its own in a movie clip on the root level. I think I found this Script, in a Macromedia Tech Note, but I can't get it to work...... The note called for the Sound "ID" I assumed (although I may be very wrong) that the name of sound effect would work within the brackets. This is the ActionScript that I have attached to the button:

on(release){
gotoAndPlay(205);
_root.mysound.stop(["Savage 2.aif"]);
playing = false

}

Thanks for your help

Stop Sound From MC
Hi

I have a movie loop playing on the main timeline.

I am trying to stop the sound on the main timeline from a button inside an
MC.
I have tried these three scripts, but they did not work: -

on (release) {
stopAllSounds ();
}

on (release) {
_root.stopAllSounds ();
}

on (release) {
_level0.stopAllSounds ();
}

Any suggestions?

HELP Stop Sound
I need to stop a single sound, and not all of the sound playing

Stop ALL Sound?
hi, i know how stop a particular sound with the .stop() command,

but i have a button which i wish to script to disable ALL sound events in the whole movie. so even though there will be commands saying soundX.start(); i wish to do this without using an if statement on each and every sound to see if the instance is on.

is this possible, its a bit like a button you find on flash web pages which disables sound so im sure its possible..

Copyright © 2005-08 www.BigResource.com, All rights reserved