3 Replies Latest reply on Jan 23, 2014 9:41 AM by AmintaAdobe

    If... Else if statements with global variables

    AmintaAdobe Level 1

      Hi Folks!

       

      I have a picture of a stove that I want to move right swiping right off the stage and left swiping left off the stage.

       

      The stove, at the beginning, is in the center of the stage.

       

      So, I created 3 intial global variables (I' ve inserted them in the correct position in ...edgeAction.JS as suggested in this topic:

       

      var center = true;

      var left = false;

      var right = false;

       

       

      And, in Stage -> Composition Ready, I have created 2 functions associated to the SwipeRight and SwipeLeft events. I used if...else if... statemens to check in what position my picture is.

       

       

      swipeRight = function() {

       

       

      if (left)

      {

      sym.playReverse(1000);

      var center = true;

      var left = false;

      var right = false;

      }

       

       

       

       

       

       

       

       

       

      else if (center)

       

       

       

       

      {

      sym.play("right");

      var right = true;

      var left = false;

      var center = false;

      }

       

       

      else {

      sym.stop();

       

       

      }

       

       

       

       

       

       

       

       

        }

       

       

      swipeLeft = function() {

       

       

      if (center)

      {

      sym.play("left");

      var left = true;

      var right = false;

      var center = false;

      }

       

       

      else if (right)

       

       

      {

      sym.playReverse(3000);

      var center = true;

      var left = false;

      var right = false;

      }

       

       

       

       

       

       

        }

       

       

       

       

      I think I made all things correct, but it doesn't work!

       

      Any suggestion?!

       

      You can find the Web Output and the project file here.

       

      MANY THANKS in advance for your help!

       

      Davide