2 Replies Latest reply on Feb 14, 2013 9:57 AM by TimJaramillo

    Using an array to show/hide multiple elements?

    Ashish Gatne

      I have two elements that need to be hidden:

       

      "mov-imp"

      "mov-pim"

       

      Currently, I am doing this:

       

      var arr = ["mov-imp", "mov-pim"];

       

      // This is the onclick function

      sym.$.each(arr, function(){

                          $(this).hide();

                }

      )

       

       

      What's the best way to show/hide multiple elements/symbols in AE?

       

      Thanks!

        • 1. Re: Using an array to show/hide multiple elements?
          Ashish Gatne Level 1

          I would like to add, I'd like to use this in the following syntax:

           

          var mySymbolObject = sym.getSymbol("<my aray name goes here>").play("animation");

          1 person found this helpful
          • 2. Re: Using an array to show/hide multiple elements?
            TimJaramillo Level 4

            Hi Ashish, here is how you can hide all symbols in an array on button click. I'm not sure what you're asking in your second post, if you can clarify that.

             

            Example:

            www.timjaramillo.com/code/edge/arrays_hide_objects

             

            Source:

            www.timjaramillo.com/code/edge/_source/arrays_hide_objects.zip

             

            Code on button.click event:

             

            // if this button stays at root, you can just call sym.hideObjects();

            // this is in case you nest your button inside other symbols

            sym.getComposition().getStage().hideObjects();

             

             

             

            Code on Stage.compositionReady:

             

            var arr = ["obj1", "obj2"];

             

            sym.hideObjects = function(){

                      $.each(arr, function(index, value) {

                                sym.$(value).hide();

                      });

            }