Public paste
SOUND
By: AS3 | Date: May 23 2010 20:00 | Format: None | Expires: never | Size: 423 B | Hits: 805

  1. stop();
  2.  
  3. var music:Sound = new Sound(new URLRequest("ghostwriter.mp3"));
  4. var sc:SoundChannel;
  5. var isPlaying:Boolean = false;
  6.  
  7. uit.addEventListener(MouseEvent.CLICK, stopMusic);
  8.  
  9. function stopMusic(e:Event):void
  10. {
  11.         sc.stop();
  12.         isPlaying = false;
  13. }
  14.  
  15. aan.addEventListener(MouseEvent.CLICK, playMusic);
  16.  
  17. function playMusic(e:Event):void
  18. {
  19.         if (!isPlaying)
  20.         {
  21.                 sc = music.play();
  22.                 isPlaying = true;
  23.         }
  24. }