4 Replies Latest reply on May 5, 2015 6:41 PM by Monkybomb Studios

    Timer function

    Monkybomb Studios

      Hi There guys,

       

      I need to add timers to each page of my project to return to the homepage if inactive for x seconds is there a way to apply this universally to the entire project?  How do i set the mouse inactive functions, if you can give me a hand i would be very grateful!!

       

      Thanks in advance!

        • 1. Re: Timer function
          Robyn_cpl Level 2

          Hi,

           

          I use this code below

           

          setTimeout(function ()

          {

           

          }, 1000);

           

          Every 1000 = to 1 second.

           

          The inside the {} I would add an if statement to say if (inactive ==0) then return to home page.

          I hope this helps

          • 2. Re: Timer function
            Monkybomb Studios Level 1

            Hi Thanks for the reply!

             

            Will this work if noone has touched the screen for the set limit then will return to homescreen? And where do i use this code on the trigger for each page? or do i use it on the creation complete or document ready areas?


            Your help is very much appreciated!

             

            Thanks so much in advance!

            • 3. Re: Timer function
              mads18950258 Level 1

              you could use setTimeout but remember to remove previously setTimeout objects.

               

              you would do it like this.

              **************************

              on your Stage CompositionReady

              create a 'global' variable like so

              sym.timer1;

               

              **************************

              from you symbol (scene or whatever), assign an mousemove event (for testing purpose i assigned this to the stage), within this event add the following code.

               

              clearTimeout(  sym.getComposition().getStage().timer1)

              sym.getComposition().getStage().timer1 = setTimeout(function ()

              {

              alert("hello");

              }, 1000);

               

               

              Voila, after 1 second you should get an alert, if you comment out the clearTimeout you get an alert for every time the mousemove event is executed .

              performance wise im not sure if this is the best solution, but it may do the job for you or inspire to another solution.

               

              hope it helped.

              • 4. Re: Timer function
                Monkybomb Studios Level 1

                Hey there, Thanks so much for the help this worked like a charm!! You saved my bacon haha!