1 Reply Latest reply on Jan 16, 2015 5:20 AM by jagwriter1978

    getPosition for in between two markers

    jagwriter1978

      I  hope someone can help me with a bit of code that I can't figure out - I don't even know if it's possible. The following code works fine:

       

      if (sym.getPosition() > 4000) {

          sym.getSymbol("symbol1").playReverse();

      sym.stop("symb1");

      }

      else {

      sym.stop("symb1");

      }

       

       

      What I know need to add to the code is tell it to execute those actions only when the position is between 4000 and 5000, not when it is just above 4000. Symbol1 should play if the position is between 4000 and 5000 and symbol2 when the position is above 5000. Basically, a click on this element should decide: if below 4000 do this, between 4000 and 5000 do this and above 5000 do this. A normal if - else probally doesn't suffice as my problem has three instances and not two. I have no idea how to code this though.

       

      To clarify what I want to do with this: the current code checks if a box is open (the symbol1 box is in the timeline after 4000) and either closes the box or not (because it's already closed). Now I need two boxes in the same setup. The code should check if a box is open (only one box can be open at the same time) and then closes whichever of the two boxes is open.

        • 1. Re: getPosition for in between two markers
          jagwriter1978 Level 1

          I am answering my own post - I found my solution. The following works fine:

           

          if ((sym.getPosition()> 4000)&&(sym.getPosition() < 5000)) {

              sym.getSymbol("symbol1").playReverse();

          sym.stop("symb1");

          }

          if ((sym.getPosition()> 5000)&&(sym.getPosition() < 6000)){

              sym.getSymbol("Symbol2").playReverse();

          sym.stop("symb2");

          }

          else {

          sym.stop("symb1");

          }

           

          I had forgotten to add && - with just one & it didn't work.