dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [f8]need help making sound loop suing this script

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Location
    United States
    Posts
    11

    [f8]need help making sound loop suing this script

    basically i have a button that im using as a sound on/off
    the script that a friend made for me works fine but doesnt loop and i dont know why.

    PHP Code:
    var mySound:Sound = new Sound();
    mySound.attachSound("myTrack");
    mySound.start();
    var 
    soundStarted:Boolean true;
    sound_btn.onRelease = function() {
        
    soundStarted = !soundStarted;
        if (
    soundStarted) {
            
    this._alpha 100;
            
    mySound.start();
        } else {
            
    this._alpha 30;
            
    mySound.stop();
        }
    }; 
    can somebody help me make this sound loop?

  2. #2
    Senior Member layerburn's Avatar
    Join Date
    Jul 2006
    Location
    USA
    Posts
    542
    Try this, i commented out where i made changes.

    PHP Code:
    var mySound:Sound = new Sound(); 
    mySound.attachSound("myTrack"); 
    mySound.start(0,99); //the 0 refers to how many seconds offset, 99 is how many times to loop the sound, you can adjust accordingly
    var soundStarted:Boolean true
    sound_btn.onRelease = function() { 
        
    soundStarted = !soundStarted
        if (
    soundStarted) { 
            
    this._alpha 100
            
    mySound.start(0,99); //the 0 refers to how many seconds offset, 99 is how many times to loop the sound, you can adjust accordingly
        
    } else { 
            
    this._alpha 30
            
    mySound.stop(); 
        } 
    }; 
    This is your brain. This is your brain on script.

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Location
    United States
    Posts
    11

    thanks a ton

    i tried your method but because the sound is only set for a certain amount of loops before stopping i decided to use this script

    PHP Code:
    mySound.onSoundComplete = function(){
        
    mySound.start();

    i figured this way i can keep it looping forever lol
    i do really appreciate your help on theis subject though

  4. #4
    Senior Member layerburn's Avatar
    Join Date
    Jul 2006
    Location
    USA
    Posts
    542
    Looks good.
    This is your brain. This is your brain on script.

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