2 Replies Latest reply on Jan 3, 2007 6:34 PM by sutuy

    Event.SOUND_COMPLETE

    sutuy
      <?xml version="1.0"?>
      I want to try make a sound stack. so, after i finished play the first sound it's continue with the second. i have read Adobe Flex 2 Help and i found it use Event.SOUND_COMPLETE. so, i wrote this code :

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="{initial()}">

      <mx:Script>
      <![CDATA[

      public function initial():void
      {
      speak.addEventListener(MouseEvent.CLICK,eventclick);
      firstplay.addEventListener(Event.SOUND_COMPLETE,nextsound);
      }

      public function eventclick(click:MouseEvent):void
      {
      firstplay.sound.play();
      }

      public function nextsound(nextt:Event):void
      {
      secondplay.sound.play();
      }

      ]]>
      </mx:Script>

      <mx:SoundEffect id="firstplay" source="C:\sounds\firstsound.mp3"/>
      <mx:SoundEffect id="secondplay" source="C:\sounds\secondsound.mp3"/>

      <mx:Button id="speak" label="Sound URL"/>

      </mx:Application>

      when i click speak button, i can hear the first sound playing, but not for the second. the second sound doesn't playing.
      Anyone know where's my mistake ?
        • 1. Re: Event.SOUND_COMPLETE
          chris.huston.t10 Level 3
          The SoundEffect does not issue a Sound_Complete event. The SoundChannel does so you need to apply the listener to a soundChannel. A SoundChannel is returned from a play() call so you can add the listener like this:

          public function initial():void
          {
          speak.addEventListener(MouseEvent.CLICK,eventclick);
          }

          public function eventclick(click:MouseEvent):void
          {
          var firstChannel:SoundChannel = firstplay.sound.play();
          firstChannel.addEventListener(Event.SOUND_COMPLETE,nextsound);
          }

          Vygo
          • 2. Re: Event.SOUND_COMPLETE
            sutuy Level 1
            Thank you very much! it's my mistake..... ^_^
            Btw, how about to embed the file. i always have an eror.
            the details is at Embed Sound Topic.