3 Replies Latest reply on Nov 3, 2012 11:48 AM by joel_pau

    How to use a variable?

    sc0073r Level 1



      I would like to use variables for sym.getComposition().getStage().getSymbol("Rec") so that I can type in Rec.isPlaying(); instead of copying and pasting that long code 100 times. I put my variables on the Stage with a compositionReady Event so that when the document fires up it will recognize my variables immediately. However, in the API guide it says to avoid using global variables and to use var myvar but it means I have to copy/paste in those variables on every single object I want to do this with which is hardly time saving.


      So first thing is first. It WORKS with the global variable and a compositionReady event. So I have some questions about this.


      Are the global variables being called upon every .xxxx miliseconds or are they only being called upon when an action is triggered? If it is the former, is there another event that I can put on the timeline of the main stage so that it queries my variables first everytime an action or event is triggered? I'm also banking on efficiency too. A slow game is no fun.


      Also, I have a syntax quesiton if someone can help me answer this. Can I condense this code?


      if (circ.isPlaying())


      else if (rect.isPlaying())


      else if (roundedRect.isPlaying())





      Is there another way I can just say:


      if (circ.isPlaying())







      Thanks all.