A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Check if Sound Loop Exist

  1. #1

    Check if Sound Loop Exist

    I start the site with a simple melody, and which ever link the user chooses a looping sound takes over that contains the same melody with more instruments. How do I check for that sound loop is playing: "if it has already started than don't start again, else start the loop".

    This is my logic code:

    StopAllSounds();
    if(LoopSong == true){
    LoopSong = new Sound();
    LoopSong.attachSound("Absolutely Fabulous Loop");
    LoopSong.start(0, 99999); //0 offset with 99999 loops
    }

    thanks

  2. #2
    I figured this out on my own... the thought was very simple on tracking what loops were playing. I'm sure there is a better method but this works... I'll share the knowledge if anyone needs something like this:

    I have 3 loop songs and numbered them to keep track:
    Song_1
    Song_2
    Song_3

    At the HOME of the site I placed an action and created a variable LoopSong initialized it to zero. This is where I also start the first loop song.

    StopAllSounds(); //prevent overlap sound
    LoopSong = new Sound();
    LoopSong.attachSound("Song_1");
    LoopSong.start(0, 99999); //0 offset with 99999 loops
    LoopSong = 0;

    For any of the links that you want the same song to loop, use an if statement to check if it's playing and give LoopSong a new value.

    if(LoopSong != 1){
    StopAllSounds();
    LoopSong = new Sound();
    LoopSong.attachSound("Song_1");
    LoopSong.start(0, 99999); //0 offset with 99999 loops
    LoopSong = 1;
    }

    For any links with different song loops you like to start, again just check if it's already playing, if not play it:

    if(LoopSong != 3){
    StopAllSounds();
    LoopSong = new Sound();
    LoopSong.attachSound("Song_3");
    LoopSong.start(0, 99999); //0 offset with 99999 loops
    LoopSong = 3;
    }


    Here's the site I used it
    www.jowedesigns.com

    thanks...
    www.En-TACT.com
    Last edited by En-TACT; 02-29-2004 at 06:11 PM.

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