1 Reply Latest reply on Jul 2, 2014 1:23 PM by joel_pau

    Headache with a variable! Quick help please!

    jamesfootlight Level 1

      HI,

       

      This is pretty basic but driving me mad.

       

      I have 4 bullet text boxes titles:

      bullet1

      bullet2

      bullet3

      bullet4

       

      that I want to fade in on a click, and rather than have code for each one like:

       

      sym.$("bullet1").fadeIn(1000);

      sym.$("bullet2").fadeIn(1000);

      sym.$("bullet3").fadeIn(1000);

      sym.$("bullet4").fadeIn(1000);

       

      I want to put them in a variable in creation complete:

       

      var bullets = ["bullet1", "bullet2", "bullet3", "bullet4"];

       

      and call them from click on stage:

       

      sym.$("bullets").fadeIn(1000);

       

      but it won't work!!!!

       

      Any ideas?

       

      thanks!

        • 1. Re: Headache with a variable! Quick help please!
          joel_pau Level 5

          Hi,

           

          1) You have to overturn closures. There is a tool: sym.setVariable().

          var bullets = ["bullet1", "bullet2", "bullet3", "bullet4"];

          sym.setVariable("fadeInArray", bullets);

           

          2) Then, you have to browse this array using a loop.

          $.each( sym.getVariable("fadeInArray"), function(index,item){ console.log(item) } ); // This line returns array items.

          $.each( sym.getVariable("fadeInArray"), function(index,item){ sym.$(item).fadeIn(1000) } );

           

          A better solution: you can also create a class using Edge Animate UI (for instance: fadeEffect). Then: sym.$( ".fadeEffect" ).fadeIn(1000);

          1 person found this helpful