A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: OnsoundComplete - loop

  1. #1
    Senior Member gordonart's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    267

    OnsoundComplete - loop

    I have two soundfiles that I want to loop after each other.
    I think it´s best to use OnSoundComplete and I used it before. But in this case I want to loop between two different soundfiles and i can´t figure out how to do it.

    This is how the code looks now.

    s1=new Sound();
    s1.attachSound("key1");
    s1.start(0,10);
    }
    s1.onSoundComplete = function(){
    s2=new Sound();
    s2.attachSound("key2");
    s2.start();
    s2.onSoundComplete = function(){
    s1.start(0,10);
    }
    Mattias Gordon
    illustrator/ animator

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    Just modify only the array to add more sounds or to change the number of time each individual sounds repeats:

    Code:
    var index:Number  = 0;
    var aSounds:Array = [{sound:"key1", repeat:10}, {sound:"key2", repeat:1}]
    
    function playSound():Void
    {
    	iteration = 0;
    	snd = new Sound();
    	snd.attachSound(aSounds[index]["sound"]);
    	snd.start(0, aSounds[index]["repeat"]);
    	snd.onSoundComplete = playNextSound;
    }
    
    
    function playNextSound():Void
    { 	
    		index++;
    		if(index == aSounds.length) index = 0;
    		playSound();
    }
    
    playSound();
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Senior Member gordonart's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    267
    wonderful!!!! Thanks!!!!
    Mattias Gordon
    illustrator/ animator

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