4 Replies Latest reply on Feb 26, 2011 1:30 AM by Mitch

    Dynamic Buttons and combining scripts.

    Mitch

      Title

      Dynamic Buttons and combining scripts.

      Post

      Hi,

      I have a button that changes the rotation of an image and works fine.  But, to add to the appearance of the button I thought I would dynamic image on the button that will change as the button is clicked. As individual scripts, they work fine.  Obviously when you overlay the dynamic image on top of the button, the Dynamic Image Script is executed on a click, not the script of the button underneath. 

      How do I combine the two case functions into the one script so the image will rotate and the button will change?

      Rotate Button Script:

      Case (GetAsNumber(Main_Page::cDisplay_Source_Orientation) = 0; "270 degrees";GetAsNumber(Main_Page::cDisplay_Source_Orientation) = 270; "0 degrees")

      Dynamic Image Script:

      Case (Main_Page::RotateButton = GetRepetition (Main_Page::gRotateIcon; 1); GetRepetition (Main_Page::gRotateIcon; 2);GetRepetition (Main_Page::gRotateIcon; 1))

        • 1. Re: Dynamic Buttons and combining scripts.
          philmodjunk

          Simply put both of these steps into a script and set your button to use Perform Script to run the script.

          PS. You do not need to use GetAsNumber in the first case function and you can simplify these expressions accordingly by removing it.

          • 2. Re: Dynamic Buttons and combining scripts.
            Mitch

            Thanks,

            How do you join two separate case function in the one Case script?

            • 3. Re: Dynamic Buttons and combining scripts.
              philmodjunk

              Exactly How are you using Case now?

              I think there might be some confusion here over what is meant by a "script".

              Case is not a step in a script, nor is it an option you can select in button Setup...

              It can be used inside a set field step--something that you can select in Button setup and also something you can put in a script. That's what I assumed you are doing with these case functions.

              Open Manage Scripts and create this script:

              Set Field [ Main_Page::cDisplay_Source_Orientation ; If (GetAsNumber(Main_Page::cDisplay_Source_Orientation) = 0; "270 degrees"; "0 degrees")]
              Set Field [ Main_Page::RotateButton ; If (Main_Page::RotateButton = GetRepetition (Main_Page::gRotateIcon; 1); GetRepetition (Main_Page::gRotateIcon; 2);GetRepetition (Main_Page::gRotateIcon; 1)) ]

              (You can use Case in place of IF if you want. I just prefer IF when there are only two possible outcomes.)

              Now use Button Setup... with the Perform Script option to run this new script.

              • 4. Re: Dynamic Buttons and combining scripts.
                Mitch

                Thanks.  Works well and is just what I was after.  I have linked the icon (which is an arrow indicating angle change) to the value of the Display Orientation:

                Set Field [ Main_Page::cDisplay_Source_Orientation ; If (GetAsNumber(Main_Page::cDisplay_Source_Orientation) = 0; "270 degrees"; "0 degrees")]

                Set Field [ Main_Page::RotateButton ; If (GetAsNumber(Main_Page::cDisplay_Source_Orientation) = 0 ; GetRepetition (Main_Page::gRotateIcon; 2);GetRepetition (Main_Page::gRotateIcon; 1)) ]