1 Reply Latest reply on Jul 8, 2013 4:34 PM by elainecc

    Trying to understand variables in Edge Animate

    Marlene Level 1

      I am writing ALL my code in the document.compositionReady window and have a few questions.

       

      1. I am trying to understand the use of sym.setVariable() vs using the var keyword. It seems that if I declare

      var myVar = "test" then the variable myVar is available in all my functions further down the code. So when would I use sym.setVariable("myVar","test")?

       

      2. Since I am writing all my code on document.compositionReady is it possible to edit the code in Dreamweaver. (I like the find and collapse functions in DW). I tried opening the edgeActions.js file and making some edits but they did not seem to always work.

       

      3. Back to variables. If I define a variable within a function by using the var keyword, it seems to only be available within that function. Is that true? How do I define a variable in a function that is available globally?

       

      4. Clearly I am mixing javascript, jquery and edgeAnimate API in my code. Is that ok? I am making my animations work but concerned that I am not doing this efficiently/effectively.

       

      Thanks for any tips, advice, comments.

        • 1. Re: Trying to understand variables in Edge Animate
          elainecc Adobe Employee

          Hi, Marlene-

           

          #2: You should be able to use any editor to edit the edgeActions.js file.

           

          #1,3: Variables can be declared for local scope (within the function) and attached to various scopes within the composition.  I tend to use variables attached to various symbols to maintain state within that particular scope.  For instance, in the floral sample file, I attached the game score to the game board symbol so that when it was destroyed and recreated, it would reinitialize to 0.

          http://html.adobe.com/edge/animate/showcase.html

           

          #4: That should be fine.

           

          Hope that helps answer some of your questions!

           

          -Elaine