3 Replies Latest reply on Aug 21, 2006 5:15 PM by Newsgroup_User

    How Do I Make a Toggle Button

    Comp. 792-YeIbLU Level 1
      How would I do this?

      I want to create a toggle button, so when the button is in it's default position it says "Sound On" and when clicked again it says "Sound Off" etc.
        • 1. Re: How Do I Make a Toggle Button
          Level 7


          Comp. 792 wrote:
          > How would I do this?
          >
          > I want to create a toggle button, so when the button is in it's default position it says "Sound On" and when clicked again it says "Sound Off" etc.

          There is many ways to achieve that.
          You could have movie clip with two frames, button in frame 1 with action go to nextFrame()
          and button in second frame with action go to prevFrame(); so they would toogel each other
          back and forth.

          You could have one movie clip with single frame and just an action on timeline frame:

          sound1 = new Sound(this);
          sound1.attachSound("loopSound");
          sound1.start(0, 999);
          buttonName.onPress = function() {
          (playing=!playing) ? sound1.stop() : sound1.start(0, 999);

          };

          (give button instance name "buttonName" and you all set .... )




          --
          Best Regards

          Urami


          --


          <urami>
          If you want to mail me - DO NOT LAUGH AT MY ADDRESS
          </urami>
          • 2. Re: How Do I Make a Toggle Button
            Comp. 792-YeIbLU Level 1
            urami,

            thanks for the reply. IYO which method is the better one and is there an upside or downside to either method?

            Thanks
            • 3. Re: How Do I Make a Toggle Button
              Level 7


              Comp. 792 wrote:
              > urami,
              >
              > thanks for the reply. IYO which method is the better one and is there an upside or downside to either method?

              Pretty much it goes down to your personal preference. No kidding. There is no one way in flash of
              doing the same thing, there is no pre build content, except components, so we all come with
              solutions based on the skill level or simply the projects needs.


              --
              Best Regards

              Urami


              --


              <urami>
              If you want to mail me - DO NOT LAUGH AT MY ADDRESS
              </urami>