Skip navigation
Currently Being Moderated

how can i re the sound

Mar 27, 2012 7:05 AM

how are you guys

 

here

i did this

package{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    import flash.events.Event;

import flash.media.Sound;

    import flash.media.SoundChannel;

 

public class admin1 extends MovieClip

{

var WIND:wind;  // the sound file name

var SOUNDCHANNEL:SoundChannel

 

public function admin1(){

        addEventListener(Event.ADDED_TO_STAGE,onAddedToStage)

 

        }

public function onAddedToStage(event:Event):void

        {

WIND = new wind;

           

            SOUNDCHANNEL = WIND.play()

}

}

}

 

it works but only one time i wanna the sound keep working after finished

 

thank you

 
Replies
  • kglad
    63,058 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 27, 2012 7:14 AM   in reply to thunderxlight11111

    use:

     

     

    package{

        import flash.display.MovieClip;

        import flash.events.MouseEvent;

        import flash.events.Event;

    import flash.media.Sound;

        import flash.media.SoundChannel;

     

    public class admin1 extends MovieClip

    {

    var WIND:wind;  // the sound file name

    var SOUNDCHANNEL:SoundChannel

     

    public function admin1(){

            addEventListener(Event.ADDED_TO_STAGE,onAddedToStage)

     

            }

    public function onAddedToStage(event:Event):void

            {

    WIND = new wind;

     

                SOUNDCHANNEL = WIND.play(0,1000);  loops 1000 times

    }

    }

    }

     

     
    |
    Mark as:
  • kglad
    63,058 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 27, 2012 1:56 PM   in reply to thunderxlight11111

    the soundchannel class has a soundcomplete event you can use after you remove that loop parameter from the play() method:

     

    package{

        import flash.display.MovieClip;

        import flash.events.MouseEvent;

        import flash.events.Event;

    import flash.media.Sound;

        import flash.media.SoundChannel;

     

    public class admin1 extends MovieClip

    {

    var WIND:wind;  // the sound file name

    var SOUNDCHANNEL:SoundChannel

     

    public function admin1(){

            addEventListener(Event.ADDED_TO_STAGE,onAddedToStage)

     

            }

    public function onAddedToStage(event:Event):void

            {

    WIND = new wind();

                SOUNDCHANNEL = WIND.play();

    SOUNDCHANNEL.addEventListener(Event.SOUND_COMPLETE,soundcompleteF);

    }

    private function soundcompleteF(e:Event):void{

    var rain:Rain=new Rain();

    SOUNDCHANNEL.removeEventListener(Event.SOUND_COMPLETE,soundcompleteF);

    SOUNDCHANNEL=rain.play();

    }

    }

    }

     
    |
    Mark as:
  • kglad
    63,058 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 27, 2012 11:15 PM   in reply to thunderxlight11111

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points