5 Replies Latest reply on Sep 3, 2013 5:17 AM by Ned Murphy

    how to create volume slider for flash cs 5 using action script 2.0?

    I designer

      how to create volume slider for flash cs 5 using action script 2.0?the output should like if user want to hear sound in slow pitch,medium pitch or high pitch(slow to high pitch anything).i have attach this sound to button with using this code:

      stop();

      mySoundBtn.onRelease = function () {

                mySoundC = new Sound(this);

                mySoundC.attachSound("mySoundClip");

                mySoundC.start(0, 10);  //10 represents the number of loops

                gotoAndPlay(2);

      }

       

      This sound plays till 3-4 scene ahead.

      Can anyone help me?

        • 1. Re: how to create volume slider for flash cs 5 using action script 2.0?
          Ned Murphy Adobe Community Professional & MVP

          Seee if the following tutorial helps.  If not, search Google using terms like "AS2 Sound volume" to find more like it.

           

          http://www.kirupa.com/developer/mx/volume_slider.htm

          • 2. Re: how to create volume slider for flash cs 5 using action script 2.0?
            I designer Level 1

            Hey thnx Ned.

            this sites are really helpful.but,i have used sound through button.so how it is possible to attavh the link with slider.i have created slider also.

            Below is my slider code for sound.

            onClipEvent (load) {

                mySound1 = new Sound();

                mySound1.loadSound((myScale)+"/"+(myTanpura)+"/"+(myTanpuraSwar)+"/"+(myTanpuraTempo)+".w av", true);

                mySound1.onSoundComplete = function() {

                mySound1.start();

                mySound1.start(0.058,999);

            }

            }

            onClipEvent (enterFrame) {

                downloaded = mySound1.getBytesLoaded();

                total = mySound1.getBytesTotal();

                if (downloaded != total) {

                    _root.dl = "You have to buy this software...";

                } else {

                    complete = 1;

                    _root.dl = "";

                }

                mySound1.setVolume(ratio * 2);

            }

             

            This code is working for slider.I mean it scrolls the slider.but it dosent make any effect to sound.

             

            Below is my button code.

            stop();

             

            mySoundBtn4.onRelease = function () {

             

                      mySoundC = new Sound(this);

             

                      mySoundC.attachSound("mySoundClip4");

             

                      mySoundC.start(0, 300);  //10 represents the number of loops

             

                      gotoAndPlay("play1");

             

            }

            this is on button's frame.not exactly on button.

            Button and Slider both are on diffrent scene.

            Can you plese help me out?

            • 3. Re: how to create volume slider for flash cs 5 using action script 2.0?
              Ned Murphy Adobe Community Professional & MVP

              There is only one line of code in what you show that deals with volume control....

               

                    mySound1.setVolume(ratio * 2);

               

              but i don't see where a slider has any relationship to it. 

               

              If the slider was involved somehow, it should have code that dictates the value of whatever "ratio" is.   Normally volume will be a value between 0 and 100, so you'd take the ratio of the slider's position relative to it's full possible length of travel and that would be the ratio you use to set the volume.  If it is moved half the distance then it would yield a ratio of 0.5, so you would multiply that by 100 to get a volume setting of 50.

               

              As far as the button versus the onClipEvent code goes I see no relationship since they are working with different sounds and different Sound objects.

              • 4. Re: how to create volume slider for flash cs 5 using action script 2.0?
                I designer Level 1

                Hey Ned thnx again.

                Actully am fresher to flash and am working on project which is alredy done by someone else(which is not completed and not working properly).So,i used this button code.Now button plays sound properly but my client is asking to show volume slider,which will allow user to adjust volume as per he wish.

                Can you suggest me any thing which will helo to create perfect output?

                 

                • 5. Re: how to create volume slider for flash cs 5 using action script 2.0?
                  Ned Murphy Adobe Community Professional & MVP

                  I suggested you look into a tutorial that explains how to implement in a slider volume control, and I pointed to one.  I also suggested how you might find more if you find that one hard to understand.  I also just described the basics behind what a volume control needs to do.  So short of doing it for you, I don't know what else to offer except for you to try something and show what it is if it is not working for you.  What you showed in the earlier posting had nothing discernably related to a slider in it.

                   

                  The fact you start the sound with a button will not interfere with adding a volume control as well.  I suggest you go thru a tutorial or two, separate from the project you are trying to revise, so that you might become familiar with how a volume control can be implemented and understand what it does.  Then you should be able to see how to implement it for your situation. 

                  1 person found this helpful