3 Replies Latest reply on Aug 29, 2011 9:28 PM by kglad

    Count Down with Music

    Umarus2

      Hi Can someone help me with coountdown animation:

      1. It goes down 60, 59, 58 .... while playing music
      2. On zero music and counter will stop

       

      Thanks!

        • 1. Re: Count Down with Music
          kglad Adobe Community Professional & MVP

          var yoursound:Sound=new Sound();

          yoursound.attachSound("soundID");  // assign linkage id to a library sound

          yoursound.start();

           

          var countdownI:Number;

          clearInterval(countdownI);

          countdownI=setInterval(countdownF,1000);

          your_tf.text = 60;

           

          function countdownF():Void{

          if(Number(your_tf.text)>=1){

          your_tf.text = Number(your_tf.text)-1;

          } else {

          clearInterval(countdownI);

          yoursound.stop();

          }

          }

          1 person found this helpful
          • 2. Re: Count Down with Music
            Umarus2 Level 1

            Thanks works well, but I forgot to mention to start countdown on button relese


             

            Here is my code (which doesnt work):

             

            start_btn.onRelease=countdownF

             

            var yoursound:Sound=new Sound();
            yoursound.attachSound("60 seconds");  // assign linkage id to a library sound

            yoursound.start();

             

             

            var countdownI:Number;
            clearInterval(countdownI);
            countdownI=setInterval(countdownF,1000);

             

            your_tf.text = 60;

             

             

            function countdownF():Void{
            if(Number(your_tf.text)>=1){
            your_tf.text = Number(your_tf.text)-1;

             

            } else {

             

            clearInterval(countdownI);

            yoursound.stop();

            }

            }

            • 3. Re: Count Down with Music
              kglad Adobe Community Professional & MVP

              :

               

               

              var countdownI:Number;
              var yoursound:Sound

              your_btn.onRelease=function(){

               

               

              yoursound=new Sound();

              yoursound.attachSound("soundID");  // assign linkage id to a library sound

              yoursound.start();

               

               

              clearInterval(countdownI);

              countdownI=setInterval(countdownF,1000);

              your_tf.text = 60;

              }

               

              function countdownF():Void{

              if(Number(your_tf.text)>=1){

              your_tf.text = Number(your_tf.text)-1;

              } else {

              clearInterval(countdownI);

              yoursound.stop();

              }

              }

              1 person found this helpful