[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

onSoundComplete... how do i get it to work

i have made a page containing several pictures, when the pictures are clicked they play a sound.  Next to each picture is a button which, when clicked, writes the name of the sound to an array, all of this works fine but when i push the button to play each sound in order, using the code below in particular the  "newSound.onSoundComplete = function() {" line, the code never goes through it.  i'm probably just missing something but i cannot think of anything. Can anybody help?????



on (click) {
      i = 0;
      j = _root.sounds[i];
      var newSound:Sound = new Sound(this);
      newSound.attachSound(j);
      newSound.start(13, 1);
      
      do {      
            
            newSound.onSoundComplete = function() {
                  i = i+1;                  
                  j = _root.sounds[i];
                  newSound = new Sound(this);
                  newSound.attachSound(j);
                  newSound.start(0, 1);
            };
            
      } while (i<50);
}
0
Neil_2004
Asked:
Neil_2004
1 Solution
 
negatyveCommented:
on (click) {
      var i = -1;
      newSound = new Sound();
      newSound.onSoundComplete = function()
      {
            if(i < _root.sounds.length - 1){
                  i = i + 1;
                  this.attachSound(_root.sounds[i]);
                  this.start(0, 1);
            }
      };
      newSound.onSoundComplete();
}
0
 
Neil_2004Author Commented:
i put an if statement around the bottom onSoundComplete to stop it from repeating for the length of the array but it works perfectly.  I must not be up to scratch on this language at all.
Thank you very much for your help negatyve

Regards

Neil

p.s. i'll probably be on here frequently asking questions about flash
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now