Sounds stopping immediately
- GameSQUID
-
GameSQUID
- Member since: Jul. 13, 2005
- Offline.
-
- Forum Stats
- Member
- Level 02
- Blank Slate
Hi,
When something explodes in my game, I play a sound, like this :
newexplosion.expSound = new Sound();
newexplosion.expSound.attachSound("explosi
onSound");
newexplosion.expSound.start();
But for some reason the sounds seem to stop immediately after they are triggered. I'm not sure if they stop because sounds are overlapping or not.
Any ideas?
Thanks.
- GameSQUID
-
GameSQUID
- Member since: Jul. 13, 2005
- Offline.
-
- Forum Stats
- Member
- Level 02
- Blank Slate
Ok, I seem to have fixed this (I was stopping another sound, but apparantly the Sound.stop() command stops all sounds unless you give it a parameter - very odd) but I have another problem - sometimes sounds aren't triggered at all while the code does get executed (put a trace there). Might this be because I'm trying to play too much sounds at once? Is there a limit, or are there other possible reasons?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 7/24/05 07:41 PM, fall_x wrote: Might this be because I'm trying to play too much sounds at once? Is there a limit, or are there other possible reasons?
I assume you need to use newexplosion.expSound.stop(); rather than Sound.stop()
Personally, I would attach Sound on the _root. I don't really understand why you've used
newexplosion.expSound = new Sound();
rather than
_root.expSound01 = new Sound();
The problem you may be having maybe be because the movieclip is being recreated (eg, by a keyframe on the timeline), and as a result, the sound is being destroyed along with the movieclip, before it's recreated.
- InsaneHamster
-
InsaneHamster
- Member since: Mar. 31, 2005
- Offline.
-
- Forum Stats
- Member
- Level 02
- Blank Slate
http://img140.images..image=megaman3gb.swf
thats my flash. when itloads click game in the lower right corner. what do do to make it
so that everytime u shoot evil , in the upper loeft corner the score goes up by 1?
also if you know , how do i make a timer, that i can put in the game that would count down 30 seconds and when it done it would show your score then go back to the scene menu
- GameSQUID
-
GameSQUID
- Member since: Jul. 13, 2005
- Offline.
-
- Forum Stats
- Member
- Level 02
- Blank Slate
At 7/24/05 07:51 PM, Denvish wrote:At 7/24/05 07:41 PM, fall_x wrote: Might this be because I'm trying to play too much sounds at once? Is there a limit, or are there other possible reasons?I assume you need to use newexplosion.expSound.stop(); rather than Sound.stop()
yes, that's what I'm doing, I meant Sound.stop() "in general", because that's how it is in the manual, you know, classname.method(). But I now know that it only stops all sounds if you don't pass a target_mc when creating the sound object.
Personally, I would attach Sound on the _root. I don't really understand why you've used
newexplosion.expSound = new Sound();
rather than
_root.expSound01 = new Sound();
I do this because I want the sound to be deleted automatically when my explosion movieclip is deleted, and also because I'm not sure if one sound object can play a sound multiple times simultaniously, so I'd have to create different sound objects anyway, so I place them in my explosion "object" so it's easier to keep track of them.
The problem you may be having maybe be because the movieclip is being recreated (eg, by a keyframe on the timeline), and as a result, the sound is being destroyed along with the movieclip, before it's recreated.
That's not it, the problem was at first that I stopped all sounds with the stop function that didn't have a target_mc. And the second problem was that flash can only play 8 sounds simoultaniously, so I now keep track of the sounds in an array, if the length > 5 (I need 3 other sounds that always need to play entirely, so that's why I take 5 here), I stop the one at position 0 and splice(0,1) it from the array, and this seems to work perfectly.
- GameSQUID
-
GameSQUID
- Member since: Jul. 13, 2005
- Offline.
-
- Forum Stats
- Member
- Level 02
- Blank Slate
At 7/24/05 07:52 PM, InsaneHamster wrote: http://img140.images..image=megaman3gb.swf
thats my flash. when itloads click game in the lower right corner. what do do to make it
so that everytime u shoot evil , in the upper loeft corner the score goes up by 1?
also if you know , how do i make a timer, that i can put in the game that would count down 30 seconds and when it done it would show your score then go back to the scene menu
This hasabsolutely nothing to do with my question, so please make your own topic for this.


