Javascript setTimeout
I don't seem to be able to use the setTimeout function. It says Reference error. setTimout is not defined. Is this function not a part of the javascript library or are there other ways of doing the same thing? I've been trying the following:
setTimeout(post("test"), 500);
Thanks for any help,
Chris.
Hi Chris,
technically setTimeout()
and setInterval()
are not global JavaScript functions. They are methods of the window object: http://www.w3schools.com/jsref/obj_window.asp That you can use them within a browser JS directly besides the "correct" window.setTimeout()
is due to a shortened syntax in browser JS.
As Max has no window object (it's not a browser) there is an alternative implementation for timing tasks. Check the documentation for the "Task Object"
https://docs.cycling74.com/max7/vignettes/jstaskobject