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




Stopping A Sound



So, I have this a move(game) that has 1 frame and I used properties for that frame to play some music in a loop.

How do I stop the music with actionscript code?



FlashKit > Flash Help > Flash Newbies
Posted on: 05-10-2007, 01:56 AM


View Complete Forum Thread with Replies

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

.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.

Stopping Timeline's Sound But Continue The Video's Sound
Hi folks!

I need help to solve this problem. I can't seem to get it work out.

I have a music playing in Timeline (looping forever) when the flash site starts.
In some sections of the flash site, there is a video section where users can watch a video.

When the video is played, I would like to stop the sound in Timeline so it doesn't interfere with video's sound.

For loading the video, I am using Video Object, the code is simply:

var my_conn:NetConnection = new NetConnection();
my_conn.connect(null);
var my_stream:NetStream = new NetStream(my_conn);
my_video.attachVideo(my_stream);
my_stream.setBufferTime(3);

Many many thanks in advanced for your help!!

ps: I have tried following links, but no luck to me.
http://www.kirupa.com/forum/showthre...ht=sound+video
http://www.kirupa.com/forum/showthre...ht=sound+video
http://www.kirupa.com/forum/showthre...ht=sound+video

Stopping ONE Sound
I originally set up my music to "stream" so that when the next sound started streaming it would obviously stop the first one. However, I hate streaming music because of the choppiness. If I therefore want to run the music on "event" or "start," is there a script to tell a _specific_ sound to stop playing at a particular keyframe? Do I nest it in a movie clip and then control the sound by pointing to the instance of the movie clip? Or is there an easier way? And what is the script?

Thanks so much for your help!
-Dave

Stopping Only One Sound
posted this in the sound forum, but that thing's not very active.

in the game i'm working on, i have a character with a chainsaw, and when the player presses space, the character mc goes to a frame of him chainsawing along with a chainsawing sound loop. when the player lets go of space, the character goes back to it's original frame and a stopAllSounds action is performed to stop the chainsaw loop.

the problem is though i want a music loop in the game, but i don't want the stopAllSounds action to stop it too... is there anyway to exclude the music loop, or maybe stop the chainsaw loop a different way?

thanks

Stopping A Sound
Hi!

I have an mp3 playing on scene 1. When I click a button and go to scene 2, 3, etc, I want it to stop (i want a different mp3 to play).

is there an actionscript that i'm supposed to put on the first keyframe of the next scene? or on the button that takes you there?

cheers,
jenny

Stopping One Sound But Not Another
i'm trying to make a little console in the corner of my site, that has buttons that play different sound/drum loops. the idea is that you can click on a strings sample, then click on a drum sample to play over it. i want to be able to stop one sound loop and leave the other playing, but the only way i know how to stop sound is using the "stopallsounds" action. can anyone tell me if it is possible to stop one sound while leaving another one playing?

Stopping The Sound
Situation - I have a movie with 3 different sound loops (created by a sound object)
1 sound is on the main timeline and 2 of the sound loops are embedded in MCs. All the sounds fade in and out.

Problem - How do i get a single button that can turn all the sound off all sounds or at least a button for each loop. Because when i create a button and tell it to Set the volume to zero or StopAllSounds, it only does it up until the fade script then it comes back on and fades out.

Script i'm using -
_root.music1.stop("firstSound01");
onEnterFrame = function ()
{ if (fadeIn02 == 1)
{_root.part1.music2.setVolume(music2Volume);
music2Volume = music2Volume+5;
if (music2Volume>99) {fadeIn02 = 0;
}}if (fadeOut02 == 1)
{_root.part1.music2.setVolume(music2Volume);
music2Volume = music2Volume-5;
if (music2Volume<5) {_root.part1.music2.stop("music2");
fadeOut02 = 0;}}};
music2 = new Sound();
_root.part1.music2.attachSound("secondSound02");
music2Volume = 0;
_root.part1.music2.setVolume(music2Volume);
fadeIn02 = 1;
_root.part1.music2.start(0, 999);

Stopping Sound
How do you stop a sound that you attached to a flash object after a certain duration of frames?

Stopping Sound?
Is there a way to stop sounds by using a variable?

like this: soundobject.stop(variable).

so I can stop one sound without stopping the others. I know flash wants me to use quoteation marks, but there needs to be another way.

or even if anyone knows how to stop one of many sounds running in the background.

this is sorta what my code is. im only going off memory so the codes are prob wrong so just go with me here. on the previous scene:

playthismusic = "song01"
playthisvoice = "voice01"
musicsoundobject = new Sound()
voicesoundobject = new Sound()
musicsoundobject.attachsound(playthismusic)
voicesoundobject.attachsound(playthisvoice)

and on the next scene:

musicsoundobject.play()
voicesoundobject.play()

now that works perfectly. but how do I stop only one of those sounds? i simply cant use quoted strings because it would be impossible to make the code be generically added to each object, and a variable system is all I need, but it dont work.

what can i do!?!! help!!
thanks for reading.
~thewaste.

Stopping Sound
I have a flash movie that plays music for my site. It has an on off feature for it. What I need is to make it where when someone turns the sound off and goes to another page it will not restart on the next page.

Stopping A Sound
hello all,

at the moment im stil learning flash as i only startd learning it this week for the first time.

i've got to the point where i need to make my own media player attached to the side of the site. i've managed to get it to play a track by use of a button that links to a frame in a Movie Media Symbol. but i cant stop it! also everytimne i click it it plays another track over the top. so if i click twice i get an echo and if i click loadz it sounds like one big crappy noise.

so my question is how do you manage sound properly?
i want to build it from scratch so that i know how to do it.

thanks in advance.
G

Stopping Only 1 Sound From 2
Hi,

I've had a read on the posts but can't find a clear answer to this..

I have a sound effect playing, which I want to stop and play another one at the same time, problem is i've been using sounds.sfx.setVolume(0) to turn the sound effect off, so when I play my new sound effect I can't hear anything (even though my new sound effect is not using a sound object, but is actually in the timeline)

how can I turn off my sound effect without using setvolume, so I can then play the next one?

any help appreciated.
boombanguk

[F8] Help With A Stopping Wav Sound
Im making a game where you hit something and a wav sound plays (as movie clip). The problem is, when it reaches frame 300 or so, it stops working!
I tried with an mp3 sound and it works fine, but i dont use it because mp3 have a start lagg (i need the sound to start fast). What can I do? Or how do I remove the lagg in mp3 sounds? (i tried some sound editing programs but the little start up always show)

Stopping Flv Sound
Hi people

Yet again i seem to be banging my head against a brick wall and would really appreciate your help.

My problem is thus:

I have created a video player using components to play an external flv. This was easy.

I have embeded this video player as an external swf in my main swf. This was easy.

THEN I find that when I close the external swf with the video player with this code:

pane_video.close_x.addEventListener(MouseEvent.MOU SE_DOWN,close_window);
function close_window(e:MouseEvent):void {
pane_video.gotoAndPlay("closed");
video_content.removeChildAt(0);



}

it works but the sound continues to play from the video. -_-

Is there ANY way to stop the sound when I remove the external swf using removeChild? I have other sound playing in the background but I'd even be willing for ALL sound to stop on the site if it just stops the flv sound aswell.

Many thanks in advance.

Stopping Sound
Hello, I am having trouble with my website. My website is completely flash and I have a sound button which when pressed i have sound start to play and sound waves which appear to come out of my sound button (a speaker). But the problem arises when i want to make the sound stop. I coded the button with:

on (release) {
gotoAndStop("Start");
}

"Start" is my first frame, which has a stop(); action and has:

on (release) {
gotoAndPlay(2);

}


Therefore what should happen is when the clip is loaded, nothing happens until the user presses the sound button. Then the sound should start, but then when the user presses it again, the sound should stop and it should go back to frame one.

What is happening is that the animation stops and goes back to frame 1, but the sound keeps on playing and does not stop when the button is pressed.
Please help me, I thought i did everything right, but obviously i've missed out on something.

Stopping Sound?
Hello there. I'm trying to figure out how I can stop a specific sound.

I've tried:
mySound.stop(["idName "])

With idName being my sound identifier (I named it in the linkage).

I even tried:
_root.mySound.stop(["idName "])

I also tired:
_root.Polka.stop();

and

_root.Polka.stop(["Praise_Polka.mp3"])

Polka being the name created when the mp3 was attached. Any way, none of them worked any ideas how I can fix this?

Stopping The Sound
okay, in my Flash Animation, I have a sound placed on Stage in the first scene, and it plays. But in Scene 5, I want all sounds so stop. I have tryed

PHP Code:



stopAllSounds(); 




but all it gives me is

PHP Code:



1180: Call to a possibly undefined method stopAllSounds. 




why isn't it stopping the sound and what is the code for stopping all sounds if started on different Scenes?

Stopping Sound
I have two sound tracks running at the same time, and I want a button for each of them to stop the sound. If I use stopAllSounds then all sounds stop, but I dont want that. I just want one sound to stop while the other keeps playing. Is there a way to do this?

Lil' Help With Stopping Sound?
i have a a background music in a movie clip and that movie clip is on my main timeline.

I've also set that movie clip's visibility to false and it will become true at the last keyframe of the of main timeline. My problem is even though i've set the movie clip's visibility to false, the backgroud music in that movie clip plays. How do i stop the music from playing? i only want it to play when the movie clip's visibility is true, which would happen when the main timeline reaches it's last frame.

thanks in advance.

Why Is The Sound Stopping?
Hi flash users!

I wonder if any of you can help me with a problem that is making me tear up my hair.
I have this flash project I'm working on with a kind of a gallery of sounds. I have some buttons generated by actionscript and XML that will load when pressed a set of 3 different mp3 files for each button. The thing is that after the first mp3 file, that always has 17 seconds, the second mp3, which is a song with about 5 minutes always stops with (I think) no reason at all. Sometimes it stops right in the beginning, other times around middle, and sometimes it even goes almost to the end. But no matter what, It always stops. And I don't have no idea why. Can you help me solve this mystery?


Here's the code I'm using for the buttons:









Attach Code

galshow["show"+i].playshow.onRelease = function()
{
numeroshow = this.id;
musica1 = MeuXML.firstChild.childNodes[idshow-1].childNodes[1].childNodes[numeroshow-1].childNodes[0].firstChild.nodeValue;
musica2 = MeuXML.firstChild.childNodes[idshow-1].childNodes[1].childNodes[numeroshow-1].childNodes[1].firstChild.nodeValue;
musica3 = MeuXML.firstChild.childNodes[idshow-1].childNodes[1].childNodes[numeroshow-1].childNodes[2].firstChild.nodeValue;

var tocar = new Array(musica1, musica2, musica3);
var showTune:Sound = new Sound();
showTune.loadSound("shows/"+tocar[0]+".mp3", true);
currentSound = 0;
function soundFinishedPlaying()
{
currentSound++;
if (currentSound>=tocar.length)
{
currentSound = 0;
}
showTune.loadSound("shows/"+tocar[currentSound]+".mp3", true);
}

showTune.onSoundComplete = soundFinishedPlaying;
};

























Edited: 04/24/2007 at 02:05:17 AM by BelieverPT

Stopping All But One Sound.
Hey all,

I have a background sound that I want playing all of the time. I have other sounds that play when a button is clicked. I created a function that plays a particular sound to its' related button. But inside of the function I also have a stopAllSounds(); function to stop the sounds of the other buttons. And of course, it stops the background sound.

Can anyone tell me a way to keep playing the background sound?

Thanks in advanced.

Stopping The Sound
hello,

i have programed a play button using:

on (release) {
kirupaSound = new Sound(this);
kirupaSound.attachSound("coolsound2");
kirupaSound.start(0, 1);
}


now i am trying to program the stop button to allow the user to stop mid song....

does anyone have the actionscript for this?!?!?!?

thanks.

Help Stopping A Sound
HI kirupa members!

I have followed your tutorial on "Playing Sounds using Actionscript"
great its working but I created another button to "STOP" the sound.
Please advise what the action script would be right using the same linkage
"coolsound" thanx

Sound Stopping... Please Help
Hey, i'm working on a movie and in the website and in the website i have a button called menu.. and the movie is set to stop.. then it continues when the button is pressed (it has a tween which bring in the menu)...

but since i have the movie set to stop.. the sound stops also and won't start again until the button is pressed...

how can i make the sound play non stop.. i want it to play weather they hit the button or not.. just 1 continuouse stream...

AS Not Stopping Sound How I Wish It Would
I've gone thru my flash books, another flash forum, somebody, please help me with this, i am stuck....

here's the situation: problem is getting sound to start again properly.

On the main timeline, I've got six different dialogue sound clips (same layer), with around 15 to 20 blank frames between them. When I hit the pauseButton, the sound clip stops and the movie clip stops, which is what I want. But, when I hit the play button, the movie clip starts, but, the sound won't start until the beginning of the next sound clip (on the main timeline.) I want the sound to also pick up right where it left off, as it is dialouge..

Here's my script:

pauseButton.onRelease = function() {
stop();
this._parent.little.stop();
stopAllSounds();
};
playButton.onRelease = function() {
play();
this._parent.little.play();
playAllSounds();
};

Thank you, kf

Stopping My Sound Playing Again
ok, i have my main timeline and different frames contain differnet movieclips that are played at the appropriate time. my main background music is also placed on my main time line. it plays ok but when i go into one of the movieclips and then back to the main timeline another instance of my music starts playing over the other, the more times i go to a page then back to the menu on the main time line the more instances of my music i get. Im sure there must be a simple script to limit the instances but buggered if i know what it is...

thx
lev

Stopping An Event And Sound FX
How on earth do you stop an event? Say for example I am doing an exploding event, it just explodes, then explodes again and again! I only want it to do that twice

And also I am working on a button that when you roll over it it makes a sound effect, is that possible? and if so how, because when I convert the button into a button, I can't add any effects or events !

Playing And Stopping Sound
can some one tell me an effective way to play and stop sound?

i want to konw how to stop just one sound, i looked in the help file but its a little complicated and i don't understand,

this is flash 5 i'mm talking about plaese help me.

Stopping Sound In FlashMX
In Flash MX ..I have three buttons in a scene. When each button is pressed an MP3 is played when each button is pressed again the sound stops.

Is there a way where I can have the other buttons stop when a button is pushed. In a way where it's impossible to have any two playing at the same time?

PLEASE HELP!

Stopping One Multiple Sound
Hey.

Im making an RPG ... its going very well...
more to the point, at the start of the RPG, two sound objects are created, "globalmusic" and "globalspeech".

"globalmusic" plays some looping background music without any problems.

when the player talks to someone, it opens up a text window that displays what they say, but also plays a sound with "globalspeech". but the player has the option to just press enter to shut the person up and walk away.

but stopping "globalspeech" stops sound/music from the entire game.

is there a better way of doing this? or a way of just stopping one channel of sound?

thanks.

PS - I know that I can make global speech stop a designated sound (ie: globalspeech.stop("mantalking01"), but the expression is limited only to quoted text, not variables...)

Stopping Sound Via Variable?
Is there a way to stop sounds by using a variable?

like this: soundobject.stop(variable).

so I can stop one sound without stopping the others. I know flash wants me to use quoteation marks, but there needs to be another way.

or even if anyone knows how to stop one of many sounds running in the background.

this is sorta what my code is. im only going off memory so the codes are prob wrong so just go with me here. on the previous scene:

playthismusic = "song01"
playthisvoice = "voice01"
musicsoundobject = new Sound()
voicesoundobject = new Sound()
musicsoundobject.attachsound(playthismusic)
voicesoundobject.attachsound(playthisvoice)

and on the next scene:

musicsoundobject.play()
voicesoundobject.play()

now that works perfectly. but how do I stop only one of those sounds? i simply cant use quoted strings because it would be impossible to make the code be generically added to each object, and a variable system is all I need, but it dont work.

what can i do!?!! help!!
thanks for reading.
~thewaste.

Stopping A Selected Sound
Is there a way to stop sounds by using a variable?

like this: soundobject.stop(variable).

so I can stop one sound without stopping the others. I know flash wants me to use quoteation marks, but there needs to be another way.

or even if anyone knows how to stop one of many sounds running in the background.

this is sorta what my code is. im only going off memory so the codes are prob wrong so just go with me here. on the previous scene:

playthismusic = "song01"
playthisvoice = "voice01"
musicsoundobject = new Sound()
voicesoundobject = new Sound()
musicsoundobject.attachsound(playthismusic)
voicesoundobject.attachsound(playthisvoice)

and on the next scene:

musicsoundobject.play()
voicesoundobject.play()

now that works perfectly. but how do I stop only one of those sounds? i simply cant use quoted strings because it would be impossible to make the code be generically added to each object, and a variable system is all I need, but it dont work.

what can i do!?!! help!!
thanks for reading.
~thewaste.

Stopping Sound Question
Here's another one I can't seem to figure out.

If someone comes to my site that's streaming audio (audio player), and they click a link to another site that pops up in a seperate browser, what's the script that stops the sound on my original site?

Did I ask that right? I've seen this before - even though the link they clicked is an html link - the sound still stops when another browser is opened.

I appreciate any help!!

Thanks,
Rick

Stopping Layer Sound
i created i new layer and dropped a sound on the stage. so when the movie starts to play the sound will also start to play.

my question is how can i stop this sound before it ends on its own?

thanks a bunch

Stopping Sound In A Symbol
Hello,
I have embedded a different wave file in three different symbols. I have an instance of each symbol within my timeline. 1 is replaced by 2 and 2 by 3. I can still hear 1 and 2 playing when i see 3.
How might i sound a sound playing when i no longer see the symbol on my timeline?
Thank you

Stopping Sound While Editing
I am making a flash animation to a sound track for an assignment. I have two questions.

When i press enter to play the animation i have created so far everything plays smoothly, and the song comes in as directed. Except when i stop the animation the music keeps going yet the animation stops. im sick of hearing the same track play all the way through every time i want to press play.

Second question. when trying to move characters in sync with the music i find i have to watch the entire movie from the start to get up to the frames i want to edit, other wise the music doesnt play. Say the music starts at frame 10 and i want to play from frame 100, the animation plays but i dont get any sound.

Any help would be great.
Thanks in advance

[MX04] Help With Stopping Sound .
I am loading a swf file which has a sound loop,

I have the 'volume_mc'
and two buttons which are 'stop' and 'play'.

if (_name == "volume_mc") {
_parent.volume = Int(slider._x + 50);
} else {
_parent.pan = Int(slider._x)*2;
}


when I click on the stop button, or if I bring the slider down -50,
it stops the sound loop, all work perfect,

but

it also stops every single sound that are on main.swf and any swf that I load into it.

I only want to stop the sound loop in my main swf .
how can I overcome this problem /

I would appreciate some help
I have attached the zip file.

Thanks in advance...

Stopping Sound Not Working
I'm making a piano and on a DOWN_EVENT on key, the sound starts playing. On an UP_EVENT, I want the sound to stop playing or fade out. I can't get it top stop or to fade out. It makes a clicking type sound, but never stops or really changes it's volume.

Here's the current code I'm using:

I'm dynamically creating the keyboard and adding each key to an array "Notes." I also have a sound array called mySounds. So I'm getting the index of the key and playing the equivalent note on a DOWN_EVENT.


Code:
public function onStartAudio(event:MouseEvent):void {

var note = notes.indexOf(event.currentTarget);

var audio:Sound = new Sound(new URLRequest("www/mp3/" + mySounds1[note]));

//Channel is defined privately above
channel = audio.play();
}
Then on UP_EVENT, I'm trying to stop the playing note. Eventually I want to make this polyphonic so I would have to know which notes to stop so a private "channel" variable for the class may not work, but for now I'm just trying to stop 1 note at a time wit...


Code:

public function onStopAudio(event:MouseEvent):void {

channel.stop();
}
This won't work for some reason. It makes a clicking type sound, but never stops.

I've also tried to fade out the sound with:


Code:
public function onStopAudio(event:TouchEvent):void {

while(channel.soundTransform.volume > 0){

sndTransform.volume -= .01;
channel.soundTransform = sndTransform;
trace(channel.soundTransform.volume);
}
if (channel.soundTransform.volume == 0){

channel.stop();
trace("stopped");
}
}
It'll show the volume going down on the trace statement, but it won't audibly change or ever stop playing. The only thing that works is SoundMixer.stopAll() but I don't want to stop all sounds.

Any thoughts?

Stopping Sound Effect
hey. i currently have a sound effect playing at the end of a movieclip. the problem i am having is that i only want the sound effect to play once but it is on a constant loop. the code i am using is

characterBathroom_mc.addEventListener(Event.ENTER_ FRAME, moveFrame20);
var fn20:Number = 20;
var toiletSound:Sound = new Sound(new URLRequest("toiletSoundEffect.mp3"));

function moveFrame20(e:Event):void{
if (e.target.currentFrame == 20){
characterBathroom_mc.visible = false;
toiletSound.play();
}
}

can anyone help me?

[F8] Stopping A Single Sound
I have a slight problem stopping a single sound. When I stop a soundFX, it will
stop ALL sounds. Here is the code I use:

Initalizing all Sounds:

PHP Code:




_root.mainMusic = new Sound(mainMusicMC);
_root.windFX = new Sound(windFXMC);
_root.rainFX = new Sound(rainFXMC);
_root.thunderFX = new Sound(thunderFXMC);
_root.birdFX = new Sound(birdFXMC);
_root.rockFX = new Sound(rockFXMC);
_root.splatFX = new Sound(splatFXMC);
_root.screamFX = new Sound(screamFXMC);

_root.mainMusic.attachSound("mainMusic");
_root.windFX.attachSound("windFX");
_root.rainFX.attachSound("rainFX");
_root.thunderFX.attachSound("thunderFX");
_root.birdFX.attachSound("birdFX");
_root.rockFX.attachSound("rockFX");
_root.splatFX.attachSound("splatFX");
_root.screamFX.attachSound("screamFX");

//start background music
_root.mainMusic.start(0, 999);







And here's the scream that stops ALL sounds (including background music)

PHP Code:




if (dragDead == true)
    {
        _root.screamFX.stop();
    }







The dragDead is a variable that checks if the character is dead.

Anyone know what I am doing wrong?

Stopping Loaded Sound
Music starts when my site loads using a URLRequest. I would like it to stop when I press a menu button. Then buttons are inside a MC.

var soundReq:URLRequest = new URLRequest("new_ComeFly.mp3");
var opensound:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel();
opensound.load(soundReq);

opensound.addEventListener(Event.COMPLETE, onComplete);

function onComplete(event:Event):void
{
opensound.play();
}

buttons and event listeners are in Buttons_mc

import flash.events.MouseEvent;
Angelobtn.addEventListener(MouseEvent.CLICK , Angelopage);
function Angelopage(event:MouseEvent):void {
MovieClip(this.root).gotoAndPlay("Angelo");
}
BtnMusic.addEventListener(MouseEvent.CLICK , Musicpage);
function Musicpage(event:MouseEvent):void {
MovieClip(this.root).gotoAndPlay("Music");
}
BtnVideo.addEventListener(MouseEvent.CLICK , Videopage);
function Videopage(event:MouseEvent):void {
MovieClip(this.root).gotoAndPlay("Video");
}

BtnContact.addEventListener(MouseEvent.CLICK , Contactpage);
function Contactpage(event:MouseEvent):void {
MovieClip(this.root).gotoAndPlay("Contact");
}

I'm a newbie at flash. I love to design but this coding stuff drives me crazy

Thanks for any help

Playing And Stopping Sound
I am designing a multi-media web page. One of the features is a multi track music player on each page.

I started designing this as four seperate buttons, adding 'play' sound behaviours to each. The only problem is that each sound plays over the last making a BAD NOISE.

Therefore, I tried adding 'stop all sounds' to each button as well hoping this would stop the previous track before playing the next. This didn't work as the 'stop all sounds' behaviour seemed to overwrite the 'play'.

How do I create buttons or movie clips that play music but also stop any other music before playing their own?

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

Stopping Multiple Sound
hi all,long time no see,jus wanna thx those who've helped mi in one way or another..even though some codes din work but ur helpfulness i appreciate.
=)

anyways, here's another help needed!

how to stop multiple sound objects at once? im using sound objects btw
n i dun wanna use arrays. is there anyway where i can stop them on clicking one button and all sounds objects stops? but i dun wanna use stopAllSounds() cus it'll stop my bg sound too(which i wans the bg sound to continue)

My Sound Keeps Stopping Before It's Finished
I've got this code to load some external MP3s.

audio.mp3 is the longest and the others Track1.mp3, Track2.mp3, etc. are the audio.mp3 sound chopped up into shorter sections.

The problem is that the sound often cuts out before it's finished. Why?

Oh yeah, and a big bonus would be if you can turn the onRelease button codes into a for loop or something like that so I can dynamically adjust the number of buttons.


ActionScript Code:
var soundClips:Number = 10;
var buttonX:Number = 200;

buttonInit();

function buttonInit():Void{
    var audioMC:MovieClip = this.createEmptyMovieClip("audioMC",this.getNextHighestDepth());
    bAll.bText.text = "All";
    for(var h:Number = 1; h<soundClips; h++){
        var button:MovieClip = this.attachMovie("button","b"+h,this.getNextHighestDepth());
        this["b"+h]._y = 70;
        this["b"+h]._x = buttonX;
        buttonX += 40;
        this["b"+h].bText.text = h;
        this["b"+h]._visible = false;
    }
};

var bName:String = new String();


bAll.onRelease = function():Void{
    arrow._x = this._x;
    stopAllSounds();
    var myAudio:Sound = new Sound(audioMC);
    myAudio.loadSound("audio.mp3",true);
    myAudio.onSoundComplete = function(){
        showButtons();
    }
};

function showButtons():Void{
    for(var h:Number = 1; h<10; h++){
        this["b"+h]._visible = true;
    }
};

b1.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track1.mp3";
    getSound();
};

b2.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track2.mp3";
    getSound();
};

b3.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track3.mp3";
    getSound();
};

b4.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track4.mp3";
    getSound();
};

b5.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track5.mp3";
    getSound();
};

b6.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track6.mp3";
    getSound();
};

b7.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track7.mp3";
    getSound();
};

b8.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track8.mp3";
    getSound();
};

b9.onRelease = function():Void{
    arrow._x = this._x;
    bName = "Track9.mp3";
    getSound();
};

function getSound():Void{
    stopAllSounds();
    var nextAudio:Sound = new Sound(audioMC);
    nextAudio.loadSound(bName,true);
};

Stopping Sound Not Working
I'm making a piano and on a DOWN_EVENT on key, the sound starts playing. On an UP_EVENT, I want the sound to stop playing or fade out. I can't get it top stop or to fade out. It makes a clicking type sound, but never stops or really changes it's volume.

Here's the current code I'm using:

I'm dynamically creating the keyboard and adding each key to an array "Notes." I also have a sound array called mySounds. So I'm getting the index of the key and playing the equivalent note on a DOWN_EVENT.


Code:
public function onStartAudio(event:MouseEvent):void {

var note = notes.indexOf(event.currentTarget);

var audio:Sound = new Sound(new URLRequest("www/mp3/" + mySounds1[note]));

//Channel is defined privately above
channel = audio.play();
}
Then on UP_EVENT, I'm trying to stop the playing note. Eventually I want to make this polyphonic so I would have to know which notes to stop so a private "channel" variable for the class may not work, but for now I'm just trying to stop 1 note at a time wit...


Code:

public function onStopAudio(event:MouseEvent):void {

channel.stop();
}
This won't work for some reason. It makes a clicking type sound, but never stops.

I've also tried to fade out the sound with:


Code:
public function onStopAudio(event:TouchEvent):void {

while(channel.soundTransform.volume > 0){

sndTransform.volume -= .01;
channel.soundTransform = sndTransform;
trace(channel.soundTransform.volume);
}
if (channel.soundTransform.volume == 0){

channel.stop();
trace("stopped");
}
}
It'll show the volume going down on the trace statement, but it won't audibly change or ever stop playing. The only thing that works is SoundMixer.stopAll() but I don't want to stop all sounds.

Any thoughts?

Stopping Sound Without A Button
I have a sound playing during a game. When it gets to the win screen it plays at the same time as the sound for the win screen. I want it to stop and play the other but I get an error message when I try:

music.stop();
and stopAllSounds();

I put these inside the functions "increaseScore" and "decreaseEnergy" becuase this is where you either win or lose.

How do I turn off the one sound and turn on the other sound without an error?

stop();
var monstersInGame:uint;
var monsterMaker:Timer;
var container_mc:MovieClip;
var cursor:MovieClip;
var score:int;
var energy:int;
var lose:Sound = new Lose();
var win:Sound = new Cheer();
var music:Sound = new Music();

function initializeGame():void
{
monstersInGame = 10
monsterMaker = new Timer(1000, monstersInGame);
container_mc = new MovieClip;
addChild(container_mc);

monsterMaker.addEventListener(TimerEvent.TIMER, createMonsters);
monsterMaker.start();

cursor=new Cursor ();
addChild(cursor);
cursor.enabled = false;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);

score = 0;
energy = energy_mc.totalFrames;
energy_mc.gotoAndStop(energy);
music.play(100, 20);
}

function dragCursor(event:MouseEvent): void
{
cursor.x=this.mouseX;
cursor.y=this.mouseY;
}

function createMonsters(event:TimerEvent):void
{
var monster:MovieClip;
monster = new Monster;
monster.x=Math.random() *stage.stageWidth;
monster.y=Math.random()*stage.stageHeight;
container_mc.addChild(monster);
}

function increaseScore():void
{
score ++;
if(score>=monstersInGame)
{
monsterMaker.stop();
gotoAndStop(2);
win.play();
}

}

function decreaseEnergy():void
{
energy --;
if(energy <=0)
{
monsterMaker.stop();
gotoAndStop(3);
lose.play();
}
else
{
energy_mc.gotoAndStop(energy);
}
increaseScore();
}
initializeGame();
function showWinLose(endMessage:String):void
{
var winLose:MovieClip;
winLose = new WinLose();
addChild(winLose);
winLose.end_txt.text = endMessage;
}

Stopping A Sound In Another Movie
i have a sound playing in the main swf via the sound object. i have another swf loaded over that one and i need a button on the 2nd swf to stop the sound in the first swf.

Sound Stopping Before Its Finished
Hey I am using the Sound object to play a song and I want to detect when the song finished, the only problem is that it stops a few milliseconds early and thus does not tigger the SOUND_COMPLETE event, i did a trace and in the song i am using for example it is stopping on frame 44364 when the length of the sound is 44591

anyone know what might be causing this?

thx

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