onSoundComplete... how do i get it to work

Posted on 2004-11-22
Last Modified: 2010-04-07
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.start(13, 1);
      do {      
            newSound.onSoundComplete = function() {
                  i = i+1;                  
                  j = _root.sounds[i];
                  newSound = new Sound(this);
                  newSound.start(0, 1);
      } while (i<50);
Question by:Neil_2004
    LVL 27

    Accepted Solution

    on (click) {
          var i = -1;
          newSound = new Sound();
          newSound.onSoundComplete = function()
                if(i < _root.sounds.length - 1){
                      i = i + 1;
                      this.start(0, 1);

    Author Comment

    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



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

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
    In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now