SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Pluxus. Fred2D's Avatar
    Join Date
    Jun 2003
    Location
    EU, Sweden
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I loop a sound-file using Actionscript 3?

    Hey y'all!

    I got a little question.

    I have a 50 sec sound-file that I want to loop in my Flash application.

    Actionscript 3 is what I'm using.

    Thanks,

    Fred

  2. #2
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not 100% sure on how this works in Flash, but the classes should be the same:

    Code:
    import flash.net.URLRequest;
    import flash.media.Sound;
    
    var url:URLRequest = new URLRequest("sound.mp3");
    var snd:Sound = new Sound(url);
    snd.play(0, 0);
    The Sound.play method takes three arguments. The first two are 1) start time and 2) loops. If you want to have it loop indefinitely you could create an event listener for when the sound stops and call a function to play the sound again.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •