3 Replies Latest reply on Feb 9, 2007 5:21 AM by Newsgroup_User

    Very Very Basic

    Donnyoddlegs
      I have been using flash for a while now but still rely on simple dodges than doing things the correct/better way. A good example is my toggle button that sets a movie clip to invisible when pressed.

      I know lots of ways of using the button as a simple toggle (on/off switch) but I tried this today and I dont understand why it dosnt work. Could anyone tell me (am am sure its obvious) and prehapes offer a better/workable alternative.

      on (release) {
      if (_root.clip_mc, _visible, false) {
      setProperty (_root.clip_mc, _visible, true);

      } else if (_root.clip_mc, _visible, true) {
      setProperty (_root.clip_mc, _visible, false);

      }
      }


      Any help would be great to help me lift myself from novice status.

      Thanks
        • 1. Re: Very Very Basic
          Level 7
          Hi!

          To follow the style of your programming you need to use the getProperty
          function in the if test, so
          if (getProperty(_root.clip_mc, _visible) == false) {
          ...
          }else if (getProperty(_root.clip_mc, _visible) == true) {
          ...
          }

          But depending on your Flash version, you might want to change your code to:
          on (release) {
          if (_root.clip_mc._visible == false) {
          root.clip_mc._visible = true;
          } else if (_root.clip_mc._visible == true) {
          _root.clip_mc._visible = false;
          }
          }

          or even more compact:
          on (release) {
          root.clip_mc._visible = !_root.clip_mc._visible;
          }

          /Jensen/

          "Donnyoddlegs" <webforumsuser@macromedia.com> wrote in message
          news:eqhpec$9u7$1@forums.macromedia.com...
          >I have been using flash for a while now but still rely on simple dodges
          >than
          > doing things the correct/better way. A good example is my toggle but that
          > set a
          > movie clip to invisible when pressed.
          >
          > I know lots of ways of using the button as a simple toggle (on/off switch)
          > but
          > I tried this today and I dont understand why it dosnt work. Could anyone
          > tell
          > me (am am sure its obvious) and prehapes offer a better/workable
          > alternative.
          >
          > on (release) {
          > if (_root.clip_mc, _visible, false) {
          > setProperty (_root.clip_mc, _visible, true);
          >
          > } else if (_root.clip_mc, _visible, true) {
          > setProperty (_root.clip_mc, _visible, false);
          >
          > }
          > }
          >
          >
          > Any help would be great to help me lift myself from novice status.
          >
          > Thanks
          >


          • 2. Re: Very Very Basic
            Donnyoddlegs Level 1
            Thanks the first way works great. I can now see the logic in it...that you have to 'getProperty' before you can make tests on it to set it. Thankyou.

            The compact method is even better just switching from one state to another in one statement...unfortunately I couldnt get that to work.

            Thank you very much!
            • 3. Re: Very Very Basic
              Level 7
              The second one should work in Flash player 6 and later (I think). What
              version are you using?

              Btw, I see I had a little typo in my code. I wrote "root" instead of
              "_root".

              /Jensen/

              "Donnyoddlegs" <webforumsuser@macromedia.com> wrote in message
              news:eqhrn8$cff$1@forums.macromedia.com...
              > Thanks the first way works great. I can now see the logic in it...that you
              > have
              > to 'getProperty' before you can make tests on it to set it. Thankyou.
              >
              > The compact method is even better just switching from one state to another
              > in
              > one statement...unfortunately I couldnt get that to work.
              >
              > Thank you very much!
              >