Skip to main content
mauricem91902475
Participating Frequently
September 6, 2022
Question

Change Time Delay / Timeout on touchscreen for single frame

  • September 6, 2022
  • 1 reply
  • 334 views

Hi,

 

I have an interactive touchscreen with 7 screens. If the screen is idle for more than two minutes the screen reverts to the home/start screen.

 

This is the code on the home/start screen:

 

var root = this;
var delay = 120000;
var timeout = 0;

function main()
{
root.stop();
root.startButton.on("click", start);
anim_container.addEventListener("mousedown", wake);
anim_container.addEventListener("mousemove", wake);
}

function start(e)
{
root.gotoAndStop(1);
}

function wake(e)
{
clearTimeout(timeout);
timeout = setTimeout(idle, delay);
}

function idle()
{
root.gotoAndStop(0);
}

main();

 

-----------------------

 

I need to add a 4 min video to one of the frames, but the timeout kicks in at 2 minutes. I can increase the timeout but this isn't suitable. Is there any way to reset the delay time just for the video frame ?

Any help appreciated

Thanks

M

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    September 6, 2022

    after two minutes (or whenever you want to reset your timer) use:

     

    anim_container.dispatchEvent(new Event("mousemove"));

    mauricem91902475
    Participating Frequently
    September 6, 2022

    Many thanks for the response.


    I'm relative new to javascript. In order to test, I have set the var delay value on homescreen to:

    var delay = 5000;

    And on the video frame I added:

    this.stop();

    anim_container.dispatchEvent(new Event("mousedown", wake1));

    function wake1()
    {
    clearTimeout(timeout);
    timeout = setTimeout(idle, 10000);
    }

     

    But when I click the link to the video from the homepage, which autoplays, it timesout after 5 seconds and not the expected 10 seconds.
    I'm doing something wrong, but the question is where?

     

    kglad
    Community Expert
    Community Expert
    September 6, 2022

    use the code i suggested