A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [RESOLVED] Sound not playing?

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    24

    resolved [RESOLVED] Sound not playing?

    Hi there, in my coding I have this function:
    Actionscript Code:
    if(!mainJumping){
                    if(Key.isDown(38) || Key.isDown(87)){
                            if(!mainOnLadder){
                                mainJumping = true;
                                jumpSpeed = jumpSpeedLimit*-1;
                                mcMain._y += jumpSpeed;
                                jumpsound = new Sound(this);
                                jumpsound.attachSound("jump");
                                jumpsound.start();
                            }
                    }
            }
    and it all worked fine.
    Then I added a pause menu, and thus added this in the onEnterFrame function (containing this jump function):
    Actionscript Code:
    if(!gamePaused){
    so that everything would only happen when the game isn't paused. As a result the sound won't play... This is the only function I added to the script (well, aside from the actual variable: var gamePaused:Boolean = false). Everything else, including physically jumping, works fine. What's wrong?

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Is that code in a nested movieclip, while the actual Boolean Variable on another level? Try !_root.gamePaused and also try tracing gamePaused, to see if it exists or not and its current value!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    24
    Nope, the code is in the same layer as the boolean variable - an actions layer. I tried !_root.gamePaused anyway, no different
    gamePaused is working, as everything else works within the onEnterFrame - moving, jumping, etc. You can see in the code I pasted where it says 'mainJumping = true', saying that the character jumps - this function works. It seems only the sound won't play.
    Do booleans stop sounds or something?

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Post FLA file, maybe?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Junior Member
    Join Date
    Dec 2011
    Posts
    24
    Okay, here's a strimmed-down version. The scripting is exactly the same, I just made all the shapes and stuff basic
    Thanks for your time!

    EDIT: I've re-posted it below as an earlier version.
    Last edited by JimbobD; 02-05-2012 at 05:15 PM.

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    older format please D:
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Junior Member
    Join Date
    Dec 2011
    Posts
    24
    Sorry for the delay, here it is - it's CS4 if that's okay. I can't get it any earlier through the program itself
    Last edited by JimbobD; 02-07-2012 at 01:18 PM.

  8. #8
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    oh, I feel so stupid when I realized what was wrong -.-*

    remove this from this:

    Code:
    jumpsound = new Sound(this);
    Actionscript Code:
    jumpsound = new Sound();
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  9. #9
    Junior Member
    Join Date
    Dec 2011
    Posts
    24
    Thank you so much, I can't believe I didn't see that!

  10. #10
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    haha, we all overlook those obscure mistakes, so no problem
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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