Quantcast
Channel: Adobe Community : All Content - Edge Animate
Viewing all articles
Browse latest Browse all 9897

If... Else if statements with global variables

$
0
0

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


Viewing all articles
Browse latest Browse all 9897

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>