A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: sound doesn't stop SOMETIMES?

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    26

    Question sound doesn't stop SOMETIMES?

    Hi... I would really appreciate some help with this please... Thank you very much ahead of time!!!

    I have movie clip buttons with a dynamic sound withing a slide show. Slide show consists of 3 movie clips connecting on frames 1, 300 and 900. The movie clip buttons with sound over are within the connecting movie clips. My problem is that although the sound and buttons work fine most of the time, sometimes, particularly if I mouse over the button wile it's transitioning on one of the connecting frames (300, 900), the sound doesn't stop... I'm sure I'm missing something in the Action Script?? Here's the script I'm using for the buttons:

    stop();

    import flash.display.MovieClip;
    import flash.events.MouseEvent;

    var req:URLRequest = new URLRequest("blend.mp3");
    var sound:Sound = new Sound();
    var controller:SoundChannel;

    function soundLoaded(event:Event):void
    {
    controller = sound.play();
    controller.stop();

    this.addEventListener(MouseEvent.ROLL_OVER, playSound);
    this.addEventListener(MouseEvent.ROLL_OUT, stopSound);
    this.addEventListener(MouseEvent.CLICK, onClickHandler);
    this.addEventListener(MouseEvent.MOUSE_DOWN, onPressHandler);
    this.addEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);

    }

    // if you want a hand cursor
    this.buttonMode = true;
    this.useHandCursor = true;

    function playSound(myEvent:MouseEvent) {
    trace("On");
    this.gotoAndPlay("one");
    controller = sound.play();
    }
    function stopSound(myEvent:MouseEvent) {
    trace("Out");
    this.gotoAndPlay("two");
    controller.stop();



    }
    function onClickHandler(myEvent:MouseEvent) {
    trace("I waited for Press AND Release!!!");
    this.gotoAndPlay("three");
    }
    function onPressHandler(myEvent:MouseEvent) {
    trace("Press");
    }
    function onReleaseHandler(myEvent:MouseEvent) {
    trace("Release");
    this.gotoAndPlay("four");
    }


    sound.addEventListener(Event.COMPLETE, soundLoaded);
    sound.load(req);


    Thank you!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Use a class like this, which has a Singleton pattern and can exist as only one instance.

    http://flashscript.biz/Flash10/inshort/PlayOneSound.php
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    26
    Thank you Cancerinform - I'll give it a shot!

  4. #4
    Junior Member
    Join Date
    May 2010
    Posts
    26
    Hmm... I'm really new to AS... I can't get it to work.. I looked over some tutorials and what I did was copy the class and paste it into new action script file, dropped it in the same folder as my animation and connected it to the movie clip where it should play via properties... I'm assuming that's totally wrong? Sorry if this sounds very ignorant...

Tags for this Thread

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