15 Replies Latest reply on Feb 8, 2015 2:07 PM by dreaminkiss

    Enable Disable buttons (was: enable disable)

    dreaminkiss Level 1

      Hello All;

       

      I am using the following code to disable the button, once it is clicked.

       

      sym.disable = function() {  

      console.log("disable"); 

      sym.$("v01").unbind("click"); 

      }

       

      However, if there is another button, that is clicked, that is NOT in sequence, with the button, then I need to ENABLE all buttons on the stage again.

       

      The button names are named as: v01 - v100 (The ending number changes per page)

      Lets say that the buttons

      v01, v04, v07, v10, v20

      are in the same sequence.

      And the buttons

      v02, v03, v08, v15, v19

      Are in another sequence.

       

       

      So, if you click the buttons

      v01, v10, and then you click v02

      The action will need to be:

      Reset ALL buttons on the stage, to be ENABLED again.

       

       

      Thanks

      wayne

        • 1. Re: enable disable
          resdesign Adobe Community Professional & MVP

          Try this:

          add a variable to check the status of your buttons

          var A = 0;

           

          on the click event

          if (A==0){

          // unbind;

          A==1;

          }

          if (A==1){

          // bind

          A==0;

          }

          • 2. Re: enable disable
            dreaminkiss Level 1

            I tried your code, and it does not work properly, Maybe I am using it incorrectly.
            However, I created an example project.
            Please read the Read me file, located in the main folder.
            Hope you can assist
            Wayne
            http://www.darkeffects.com/up/example.zip

            • 3. Re: enable disable
              resdesign Adobe Community Professional & MVP

              Here is how I'd do it. Code is in compositionReady except for the showButton. Might not be the best way but it works. You can click on the buttons in any order.

              comment out your code in the buttons and try it out.

              Buttons Revised.zip - Box

              // insert following code in compositionReady

              // insert code to be run when the composition is fully loaded here

              var V1 = 0, V2 = 0, V3 = 0, V4 = 0;

               

               

              sym.$('v01').bind('click', function(){

                sym.$('v01').unbind('click');

                if(V1==0){

                sym.$("v01").css({"background-color":"#FF0000"});

                V1 = 1;

                }

                if (V1==1 && V2==1 && V3==1 && V4==1){

                sym.$("ShowButton").show();

                }

              });

               

               

              sym.$('v02').bind('click', function(){

                sym.$('v02').unbind('click');

                if(V2==0){

                sym.$("v02").css({"background-color":"#FF0000"});

                V2 = 1;

                }

                if (V1==1 && V2==1 && V3==1 && V4==1){

                sym.$("ShowButton").show();

                }

              });

               

               

              sym.$('v03').bind('click', function(){

                sym.$('v03').unbind('click');

                if(V3==0){

                sym.$("v03").css({"background-color":"#FF0000"});

                V3 = 1;

                }

                if (V1==1 && V2==1 && V3==1 && V4==1){

                sym.$("ShowButton").show();

                }

               

               

              });

               

               

              sym.$('v04').bind('click', function(){

                sym.$('v04').unbind('click');

                if(V4==0){

                sym.$("v04").css({"background-color":"#FF0000"});

                V4 = 1;

                }

                if (V1==1 && V2==1 && V3==1 && V4==1){

                sym.$("ShowButton").show();

                }

              });

              • 4. Re: enable disable
                dreaminkiss Level 1

                This is not working.

                In your example, you have to choose ALL buttons on the stage, in order for the Show Button to show.

                That is defeating the purpose of what I showed in my example.

                 

                 

                See.

                You choose

                Button 1, 3 (This shows the button)

                Button 2, 4 (This shows the button)

                Button 1,2 (This should RESET everything)

                Button 1, 4 (Reset)

                 

                 

                Basically, everything that is NOT in the sequence, will be reset.

                In your example, you have to choose everything, and that will not work.

                • 5. Re: enable disable
                  dreaminkiss Level 1

                  I changed your code, to work in Sequence.
                  However, it is NOT resetting, when you choose something
                  That is NOT in sequence.
                  Code Changed.

                   

                  // insert code to be run when the composition is fully loaded here

                  var V1 = 0, V2 = 0, V3 = 0, V4 = 0;

                   

                   

                  sym.$('v01').bind('click', function(){

                    sym.$('v01').unbind('click');

                    if(V1==0){

                    sym.$("v01").css({"background-color":"#FF0000"});

                    V1 = 1;

                    }

                    if (V1==1 && V3==1){

                    sym.$("ShowButton").show();

                    }

                  });

                   

                   

                  sym.$('v02').bind('click', function(){

                    sym.$('v02').unbind('click');

                    if(V2==0){

                    sym.$("v02").css({"background-color":"#FF0000"});

                    V2 = 1;

                    }

                    if (V2==1 && V4==1){

                    sym.$("ShowButton").show();

                    }

                  });

                   

                   

                  sym.$('v03').bind('click', function(){

                    sym.$('v03').unbind('click');

                    if(V3==0){

                    sym.$("v03").css({"background-color":"#FF0000"});

                    V3 = 1;

                    }

                    if (V1==1 && V3==1){

                    sym.$("ShowButton").show();

                    }

                   

                   

                  });

                   

                   

                  sym.$('v04').bind('click', function(){

                    sym.$('v04').unbind('click');

                    if(V4==0){

                    sym.$("v04").css({"background-color":"#FF0000"});

                    V4 = 1;

                    }

                    if (V2==1 && V4==1){

                    sym.$("ShowButton").show();

                    }

                  });

                  • 6. Re: enable disable
                    resdesign Adobe Community Professional & MVP

                    Oops! Sorry - I did not get that! I will try and get you a file as you want.

                    Thanks for your patience.

                    • 7. Re: enable disable
                      dreaminkiss Level 1

                      Patients is something that everyone needs to have.
                      Take your time resdesign.

                      • 8. Re: enable disable
                        resdesign Adobe Community Professional & MVP

                        OK. Download the updated file from the same link above. I am not sure this is totally right but try it.

                        Thanks.

                        • 9. Re: enable disable
                          dreaminkiss Level 1

                          I downloaded the file.

                          I looked at the codes, in both folders, and in all files, and they are the same exact codes as the very first one that you sent.

                          Of which, is doing this

                           

                           

                            if (V1==1 && V2==1 && V3==1 && V4==1){

                           

                           

                          instead of this

                            if (V1==1 && V3==1){

                           

                           

                          Basically, I do not see where the code has changed any.

                           

                           

                          OR

                          The file is NOT updated through the link that you had provided before.

                          Maybe I am grabbing the same file.

                          As it is the same size as the original one.

                          • 10. Re: enable disable
                            dreaminkiss Level 1

                            I checked the file sizes, and they are the exact same.
                            So, it seems that the link above, is not updating with the new uploaded file.
                            Let me know when you have it corrected and I will give it another try.

                            • 11. Re: enable disable
                              resdesign Adobe Community Professional & MVP

                              Sorry. Try again. Not sure this is exactly what you want.

                              • 12. Re: enable disable
                                resdesign Adobe Community Professional & MVP
                                1 person found this helpful
                                • 13. Re: enable disable
                                  dreaminkiss Level 1

                                  I am going through the code right now.
                                  Running the project, if you click
                                  1 and 3
                                  or
                                  2 and 4
                                  Then it will show the button
                                  However, if you click
                                  3 and 1
                                  or
                                  4 and 2
                                  It will allow you to click ALL of the buttons.
                                  So the code is limited to only doing 1 direction, instead of either way.

                                   

                                  And looking at the code, I can see now, that if I have 35 units on the stage, it is going to be a very long, long, coding process.

                                   

                                  I am going to play around with what you have provided, and see if I can get it to work the way that I need it to work.
                                  I will let you know.
                                  And i want to thank you for your time, that you have spent in working on this for me.

                                   

                                  Take care and have a wonderful rest of the weekend.
                                  Wayne

                                  • 14. Re: enable disable
                                    resdesign Adobe Community Professional & MVP

                                    You did not mention you wanted to go in different directions so I did not

                                    plan for it. I will think some more about  the process.

                                    I have a lot of work this week but I will try to get to is before the end

                                    of the day.

                                     

                                    On Sun, Feb 8, 2015 at 3:06 PM, dreaminkiss <forums_noreply@adobe.com>

                                    • 15. Re: enable disable
                                      dreaminkiss Level 1

                                      Yes, it is an all direction project.
                                      going one direction, would not work really well.
                                      Look forward to seeing what you can come up with.