actionscript 3 - how to wait for a few seconds before starting a function -


i want reload gun. when r pressed. want wait 3 seconds before loading gun. there simple way this?

example:

if (event.keycode == keyboard.r)         {             //wait(4 seconds)                             // start reloading         } 

var reloadtimer = new timer(4000,1); //add 4 second timer reloadtimer.addeventlistener(timerevent.timer_complete,reload);  function handlekeypress(event:keyboardevent):void {     if (event.keycode == keyboard.r)     {         reloadtimer.reset() //in case still going (otherwise add check if reloading)         reloadtimer.start();     } } 

when key pressed, start 4 second timer. @ end of 4 seconds, reload function execute. should put code reloading in there.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -