A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: stepping sound

  1. #1
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30

    stepping sound

    I made a little game for pigs to play
    moving a ball on the screen "mani"pulating
    a joystick with their snout.

    The thing is that I would like a sound to be triggered
    when the ball symbol is moving, so that the pig will registre
    an audible responce.

    Im using a script for the joystick movement
    from www.bigredswitch.co.uk - and would like a solution
    wich operates from the _x _y pos of the ball obj,
    rather than the joystic input.
    Mainly because I can't see how the latter should be done.

    -hjw

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Location
    Breda, The Netherlands
    Posts
    522

    snout-iptulating

    Hi Hans,

    If your object is a movie clip. You can just check the x and y properties of the ball. Put them in a variable. When the variable changes play the sound, otherwise don't.

    Or maybe I didn't understand you correctly?

    HTH, Danielle.

  3. #3
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    thats exactly what I would like.
    But im rather new to actionscripts
    so could you how you would write it.

    how to put them in a var
    and what the frame action would look like.

    -hjw

  4. #4
    Senior Member
    Join Date
    Mar 2001
    Location
    Breda, The Netherlands
    Posts
    522
    I'll try and put a simple fla together. It may take a little while. It is flash mx?

    Danielle.

  5. #5
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    yes it is

    thanks alot

    -hjw

    you can see a online ver at www.hjw.dk/grynt

  6. #6
    Senior Member
    Join Date
    Mar 2001
    Location
    Breda, The Netherlands
    Posts
    522

    zip

    Hi,

    You can find the fla here:
    http://www.numuseum.com/diversen/sound.zip

    HTH, Danielle.

  7. #7
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    Got it running yesterday, had to move an "}" a few lines.

    It works nice with the joystick.
    the only thing I really need to solve now, is the timing of the sound.

    I get to many "playsound" objects running at the same time.
    like 60 a sec. And it dosn't sound nice, but you know you've been moving the joystick.

    I'll fumble around with "set interval" and see if I can get that to work.

    I attatch a photo of karsten and griseline.

    thanks again -hjw

    any suggestions, please post.

  8. #8
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    the photo again?
    Attached Images Attached Images

  9. #9
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    I just got a mail from karsten and svineline (not as previous mentioned griseline).
    She is doing fine - on the third day she discovered the connection between screen and the joystick. Advanced to level 3, where she scored 7 games in row.

  10. #10
    Junior Member scudsucker's Avatar
    Join Date
    Feb 2003
    Location
    Cape Town, RSA
    Posts
    1,509
    What a pretty pig!
    Hariyemadzisawira nhaka yedu! Down the SCUD and win!
    I'm too lazy to read Private Messages.

  11. #11
    Senior Member
    Join Date
    Mar 2001
    Location
    Breda, The Netherlands
    Posts
    522
    Originally posted by Hans Jacob
    It works nice with the joystick.
    the only thing I really need to solve now, is the timing of the sound.

    I get to many "playsound" objects running at the same time.
    like 60 a sec. And it dosn't sound nice, but you know you've been moving the joystick.

    I'll fumble around with "set interval" and see if I can get that to work.
    Nice that you got it working.
    I didn't actualy realize that it would be real pigs playing the game! That's great. I love pigs.

    I've been trying to work on some solutions but I can't figure it out at the moment. The direction you should be looking might be:

    1) Do something with test_sound.onSoundComplete = function(){
    // do something only when the previous sound has stopped
    };

    2) make the if (_root.ball._x != xpos) less sensitive, for example only when it's _root.ball._x + 5

    Hope you can work it out. I couldn't. You can also post sound questions on the sound board here. Or check out this tutorial: http://www.kennybellew.com/

    Good luck, Danielle.

  12. #12
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    I think that the != inequallity will only be more stressed
    if you add +5 - it will then never stop playing - I think!?

    quote:
    2) make the if (_root.ball._x != xpos) less sensitive, for example only when it's _root.ball._x + 5

  13. #13
    Senior Member
    Join Date
    Mar 2001
    Location
    Breda, The Netherlands
    Posts
    522
    Originally posted by Hans Jacob
    I think that the != inequallity will only be more stressed
    if you add +5 - it will then never stop playing - I think!?
    You'll have to play with it. Something like if (_root.ball._x == xpos + 5) This triggers the action only when there has been a 5 pixels movement. That's my idea.

    Danielle.

  14. #14
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30
    I tryed that in a numerous ways
    and I can't figure out how to make it == xpos +/- 5
    because the movement can be either decreasing or increasing
    and should'nt it be <== xpos+5 or ==> xpos-5
    are you able to make such if,or,then else statements

    also if you got an if / else statement
    what would the if command be ? "ignore", how do you put that?
    because if the above statement is true it should just continue.

    I messing around alot, and don't know if my actions are legaly entered

    thanks again for your help.

    I tryed to use the setinterval to pause different parts of the script functions, but with out any luck.

  15. #15
    Member
    Join Date
    Mar 2003
    Location
    Dane
    Posts
    30

    setInterval solution?

    the >= xpos +5 works in the on direction,
    when the joystick is pulled right the statement comes true after a short pace, but after that it stays true, until its released.
    It brings me back to the original problem.
    instead of going dack.. dack.. dack ... it goes
    drellllllllllllllllllllllllllllllllll...

    I will have to figure it out in another way
    running short on ideas

  16. #16
    Senior Member
    Join Date
    Mar 2001
    Location
    Breda, The Netherlands
    Posts
    522

    Worked it out

    Hi Hans,

    I think I worked it out. Please look here and let me know if it helps. You'll have to adjust the code for the y coordinates yourself.
    http://www.numuseum.com/diversen/sound2.zip

    Regards, Danielle.

  17. #17
    Senior Member
    Join Date
    Mar 2003
    Location
    Maryland
    Posts
    378
    Do you eat bacon?

    LoL I just HAD to say it

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