A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Start sound on movieclip press/drag and on mouse move

  1. #1
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971

    resolved [RESOLVED] Start sound on movieclip press/drag and on mouse move

    Hello guys! ^_^

    I keep working in this 100floors like game...phew! Is a lot of hard work! But i achieved everything until now.

    Now i have this window, and i want sound when sliding/rolling it. I already have sound when you release or stop dragging the window.
    Actionscript Code:
    windows.onRelease=function(){
    this.stopDrag();
    windowStop.start(0,1);
    }

    Now i want sound when dragging the window movieclip. I tried this:

    Actionscript Code:
    window.onPress=function(){
    this.startDrag(false, limiter._width);

    onMouseMove=function(){
    windowSlide.start(0,1);
    }

    }

    It works 90%, the sound starts when you press or start dragging the movieclip and move the mouse, the problem is the sound keeps repeating endlessly over and over. Its weird, because i put (0, 1) where "1" is start the sound "1" time. 99 Would be 99 times (like a loop)...

    I noticed that when I move the mouse 1 pixel, the sound is played as I want, but if I move the mouse few pixeles, the sound repeats every time the mouse is moved 1 pixel...what i want , is when you are dragging the movieclip, obviously moving the mouse, the sound starts and keep playing at the same time I move the mouse, and when I release the movieclip or stop drag, it stops.

    Is like when you are rolling or sliding a sliding door, or a sliding window , the sound is continious like "woosshhhh" until you stop sliding/moving/dragging/rolling it.

    Help?

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    you should set a variable when you start your drag.. and change the same variable when you stop.

    using that as a 'control var' you can then check to see if you are already 'playing' the sound.


    Also you probably do NOT want on use mouseMove alone then.. maybe add a check onMouseDown too? or something?

  3. #3
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi,

    do you mind posting the sound file?
    I am back, guys ... and finally 18 :P

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

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Sure!



    Explanation:
    As you can see, the sound while you are dragging the window, repeats and repeats, althought the sound loop is set to "1", play once.

    I understand the issue, each pixel you move the mouse left or right, it starts the sound again. I want a way to only play the sound if it is not playing!


    Fixed! Thanks to whispers:

    I created
    Actionscript Code:
    var isPlaying=false;
    Then i put this:

    Actionscript Code:
    onMouseMove=function(){
        if(isPlaying==false){
        ventana.start(0,1);
        isPlaying=true;
        }
        ventana.onSoundComplete=function(){
            isPlaying=false;
        }


    And that did the work! The sound starts only if it isn't playing! Omg!
    Thanks nig! You can see level 3 of my game jeje! When I am working in level 15 (actually level 7), I will show you the whole game! Thanks both


    Here is the issued fla, so you can experience the bug http://www.mediafire.com/?v13qicyp3b9ovey And then you can add the fixed script to it and see how it works now!

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