0 Replies Latest reply on Nov 28, 2014 12:52 PM by Sandies

    Trigger an animation only once in Adobe Edge

    Sandies

      I am using this code http://www.timjaramillo.com/code/edge/_source/gyroscope.zip to start an animation on the Edge timeline when tilting the phone to the right. But I need this animation to play only once and play another animation in loop after. Right now the animation starts again each time I tilt the phone to the right, whitch is normal because the script is triggered window.ondevicemotion.. Is there a way to stop this script of happening after it runs once? Here is the complete script that I have in the "CompositionReady" code tab. As you can see I start the animation sym.play() when the status is = 1

       

      //Detect if the browser supports DeviceMotionEvent

      if (window.DeviceMotionEvent != undefined) {

       

       

        //ondevicemotion is fired when iOS device detects motion

        window.ondevicemotion = function(e) {

        //ax is the movement on the x axis.

        //This motion is used to move the ship in the game

        ax = event.accelerationIncludingGravity.x * 5;

        ay = event.accelerationIncludingGravity.y * 5;

       

       

        //Status 0 is start, 1 is left, 2 is right, 3 is stay

        if(status == 0){ //initial condition

        status = 3; //stay

        sym.$("txt_test").html("Status: level");

        }

       

       

        if(ax > 14 && status != 2){ //move right on device

        status = 2;

        sym.$("txt_test").html("Status: move right");

        }

       

       

        if(ax < -14 && status != 1){ //move left on device  

        status = 1;  

        sym.$("txt_test").html("Status: move left");

        sym.play();

        }

       

       

        if(ax > -14 && ax < 14 && status != 3){ //device held steady

        status = 3;

        sym.$("txt_test").html("Status 0");

        }

        }

      }