A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: [MX] sound stop then play problem

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Posts
    394

    [MX] sound stop then play problem

    it doesn't start playing angain
    Code:
    onClipEvent (enterFrame) {
    	stopAllSounds();
    }
    on (keyPress "<Space>") {
    	_root.snd.start(0, 10); 
    	play();
    }

  2. #2
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    It's probably because your onEnterFrame stops the sound every frame, so, even if one presses space, if will have stopped already. Also, (((((on (keyPress) "<Space>") {))))) I'm pretty sure, like, doesn't work, for the most part. Try this...

    Code:
    onClipEvent(enterFrame){
            if (_currentframe==(SOMETHINGGOESHERE)){
            stopAllSounds();
    }
    onClipEvent(keyDown){
            if (Key.isDown(32)){
    	        _root.snd.start(0, 10); 
    	        play();
            }
    }
    --SumWunGye

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    it didn't work, I got an error that I can't have on handelers inside other on handelers. Also I replaced your text something goes here,with 128. adn only your words not any of the symbols. is that right??

  4. #4
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Did you make sure my code was the ONLY code on your movie clip?
    --SumWunGye

  5. #5
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    yes here is the code

    Code:
    onClipEvent(enterFrame){
            if (_currentframe==(128)){
            stopAllSounds();
    }
    onClipEvent(keyDown){
            if (Key.isDown(32)){
    	        _root.snd.start(0, 10); 
    	        play();
            }
    }

  6. #6
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Sorry, by (SOMETHINGGOESHERE), I meant without the parenthesis.
    --SumWunGye

  7. #7
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    i got this as an error message

    **Error** Scene=Scene 1, layer=Layer 1, frame=128:Line 5: onClipEvent handlers may not nest within other onClipEvent handlers
    onClipEvent(keyDown){

    **Error** Scene=Scene 1, layer=Layer 1, frame=128:Line 1: Statement block must be terminated by '}'
    onClipEvent(enterFrame){

    **Error** Scene=Scene 1, layer=Layer 1, frame=128:Line 10: Syntax error.
    }

    Total ActionScript Errors: 3 Reported Errors: 3

  8. #8
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    sorry, missed ANOTHER parenthesis

    [code]onClipEvent(enterFrame){
    if (_currentframe==(128)){
    stopAllSounds();
    }
    }
    onClipEvent(keyDown){
    if (Key.isDown(32)){
    _root.snd.start(0, 10);
    play();
    }
    }
    --SumWunGye

  9. #9
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Code:
    onClipEvent(enterFrame){
    if (_currentframe==(128)){
    stopAllSounds();
    }
    }
    onClipEvent(keyDown){
    if (Key.isDown(32)){
    _root.snd.start(0, 10);
    play();
    }
    }
    --SumWunGye

  10. #10
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    i didn't get an error message, but unfortunately it didn't stop the sounds

  11. #11
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    WHEN do you want the sounds to stop? Because that sound stops on frame 128.
    --SumWunGye

  12. #12
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    not with the last code you provided, it just keeps playing, it doesn't stop. The sound I want to stop is the same one that I want to start in the end of that code piece

  13. #13
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Strange... Try this?

    Code:
    onClipEvent(enterFrame){
    if (_currentframe==(128)){
    stopAllSounds();
    }
    }
    onClipEvent(keyDown){
    if (Key.isDown(32)){
    _root.snd.start(0, 10);
    play();
    }
    }
    --SumWunGye

  14. #14
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Oops, ignore my last post...

    Code:
    onClipEvent(enterFrame){
    if (_currentframe==(128)){
    _root.snd.stop();
    }
    }
    onClipEvent(keyDown){
    if (Key.isDown(32)){
    _root.snd.start(0, 10);
    play();
    }
    }
    --SumWunGye

  15. #15
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    By the way, how many frames long is the layer you are putting this code on?
    --SumWunGye

  16. #16
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    still didn't work. 539.

    this is on a movie clip that I have copy and pasted the frames for like 12 times

  17. #17
    Senior Member
    Join Date
    Jan 2008
    Posts
    394
    i only have two frames. one, the movie, and another one, buttons ect.

  18. #18
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    So, on the top layer, there are 2 frames, and on the movie, located on the top layer, there are 539 frames? Is this right?
    --SumWunGye

  19. #19
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287

    You still haven't answered my question...

    Quote Originally Posted by sumwungye
    WHEN do you want the sounds to stop?

    On the click of a button? When you get to a certain frame? Et cetera...
    --SumWunGye

  20. #20
    Musical chair sumwungye's Avatar
    Join Date
    Jan 2008
    Location
    Planet Earth, third planet from the Sun
    Posts
    287
    Try this...

    First give your movie clip instance name "movieclip", then add this code to it...
    Code:
    onClipEvent(enterFrame){
    if (_root.movieclip._currentframe==128){
    _root.snd.stop();
    }
    }
    onClipEvent(keyDown){
    if (Key.isDown(32)){
    _root.snd.start(0, 10);
    play();
    }
    }
    --SumWunGye

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center