5 Replies Latest reply on Nov 28, 2010 8:22 PM by zacharyaders

    Toggle button to do two sets of actions?

    zacharyaders

      I am trying to simply hide / show a component (a graphic which scales and moves between states) with a toggle switch, which seems very difficult. (The graphic would be 100% opacity when toggle is selected (in its 2nd four states) and 0% opacity when the toggle is unselected (in its first four states).

       

      The problem seems to be that a toggle button can only do one action (or single set of actions) when clicked, rather than have 2 different sets of actions, one each in its on and off state.

       

      The only way I was able to trick this thing to kind-of-work was to make the graphic a part of the toggle button, which is turned on during the "selected" states (but of course now, the graphic cannot change automatically (location + scale) between the application states - its stuck inside the button component. I tried to even make that graphic (within the button) a custom component with multiple states (in its respective locations + scales), but I couldn't find a way to have an outside component (ex: the button that drives the changing of application states) drive the changing of states of that graphic within the toggle button.

       

      I hope my description makes sense.

       

      Is there a way to make a button that actually toggles between 2 sets of actions?

       

      thanks in advance.  -z

        • 1. Re: Toggle button to do two sets of actions?
          Peter Flynn (Adobe) Adobe Employee

          Hi Zachary,

           

          This is currently not as easy in Flash Catalyst as we'd like, but it can be done.

           

          The standard way to do this is to place your graphic inside a custom component, and give the component two states: invisible and visible.  Then your toggle button can toggle the component's state back and forth -- changing the "When in Any State" dropdown to make it do different things depending on whether the component is currently visible or not.

           

          In other words, you'd add:

          • On Click > Play Transition to State > Visible > When in Invisible
          • On Click > Play Transition to State > Invisible > When in Visible

           

          This has a downside: in Flash Catalyst CS5, putting the graphic inside a component means you can't have it resize in different states of your overall app.  This is not an issue in the next version of Flash Catalyst (codenamed "Panini"), where you can create fully resizable components.

           

          In the meantime you can work around this restriction with a little trickery -- this is messy but works like a charm.  You can use a hidden custom component to store the visible/invisible state that your interactions look at (as above), and keep the graphic itself outside the component.

           

          So, instead of the above, you'd add:

          • On Click > Play Action Sequence > When in Invisible
            • In the first action sequence, select the graphic and choose Add Action > Fade, and set it to go from 0 to 100.
            • Then also a Set Component State action to set your hidden component's state to Visible
          • On Click > Play Action Sequence > When in Visible
            • In the second action sequence, select the graphic and choose Add Action > Fade, and set it to go from 100 to 0.
            • Then also a Set Component State action to set your hidden component's state to Invisible

           

          Hope that helps!

           

          - Peter

          • 2. Re: Toggle button to do two sets of actions?
            Peter Flynn (Adobe) Adobe Employee

            ...and here's a sample FXP file that illustrates the workaround.

             

            - Peter

            • 3. Re: Toggle button to do two sets of actions?
              zacharyaders Level 1

              Peter, Thanks a million! That worked like a charm. I was trying to conceptualize some kind of controller before, but this hidden component is great! (and really not that messy). This is actually opening some other idea-doors now. Thanks again for the fast solution Z

              • 4. Re: Toggle button to do two sets of actions?
                Peter Flynn (Adobe) Adobe Employee

                No problem, glad I could help!

                 

                - Peter

                • 5. Re: Toggle button to do two sets of actions?
                  zacharyaders Level 1

                  This worked alright at first, but now when I'm changing some things later down the line, my file seems to be missing connections between those buttons when I go to preview. Even though everything is set up correctly, it is now very inconsistent to run correctly. I did some previous changes to some buttons set up this way, and i had to delete the little empty reference object and redo all of the action sets, etc to get it running correctly again. Are things like this going to be updated any time soon?