I'm using the vimeo api which reports the progress of the video playing back every second from 0.0 to 1 when the video is complete.
I want to do something when the progress is 0.66 or above but in my if loop whatever I want to do is fired continously once progress reaches 66% (0.66)
player.addEvent 'playProgress', (data, id) ->
break_loop = false
if data.percent >= 0.66 && break_loop is false
break_loop = true
off to remove event handlers. Then you could move your event handler to a named function (or at least the closest thing CoffeeScript has to named functions) and that could unbind itself when the 66% mark is reached, something like:
progress = (data) -> return if(data.percent < 0.66) do_something() player.off('timedupdate', progress) player.on('timedupdate', progress)
There might be something like
off in the old API you're using but I can't find any documentation for it.