[Javascript] causing script to pause before moving to next command

Carl Adler carl at carladler.org
Fri May 3 16:19:45 CDT 2002


Yes it will wait for the stated time to play the sound but it is not a true
pause in that any commands after the timeout will execute immediately.
Carl

> From: "Trey H" <tutwabee at hotmail.com>
> Reply-To: javascript at LaTech.edu
> Date: Fri, 03 May 2002 20:57:00 +0000
> To: javascript at LaTech.edu
> Subject: Re: [Javascript] causing script to pause before moving to next
> command
> 
> David,
> You might want to use a setTimeout() command to pause the script before it
> does its action.  Play around a little with the amount of milliseconds to
> pause it, because you might need it to be long or short depending on the
> sound.  Here is what the code might look like:
> 
> if (player[sy][sx][0] < 100) {
> /* Hit something */
> /* need to have set timeout here to delay setting image and playing sound */
> setImage(sy,sx,103,false);
> setTimeout("playSound(0)", 20); /*  Pause for 20 millaseconds */
> 
> ====================================
> Trey: tutwabee at hotmail.com
> Get free JavaScripts at the Blue Dragon!
> Just go to:
> http://www.websiter.biz
> ====================================
> Make money by being online:
> http://www.degoo.com/index.php?refid=tutwabee
> ===================================
> Earn free traffic for your website easily:
> http://tools.addme.com/servlet/popview?id=52260
> ====================================
> 
> 
> 
>> From: David Merchant <merchant at LATECH.EDU>
>> Reply-To: javascript at LaTech.edu
>> To: javascript at LaTech.edu
>> Subject: [Javascript] causing script to pause before moving to next command
>> Date: Fri, 03 May 2002 15:29:08 -0500
>> 
>> I need to have a Javascript pause after a user makes an input before the
>> computer makes its move (this is a javascript for Battleship which I'm
>> tweaking to add sound effects in). I need the computer to wait a second for
>> the sound effect from the player's move to finish before it makes a move
>> (that will have a sound effect as well).
>> 
>> I'm doing a brain fart, and can't seem to get it to work, all attempts have
>> failed to pause the script.
>> 
>> if (player[sy][sx][0] < 100) {
>> /* Hit something */
>> /* need to have set timeout here to delay setting image and playing sound
>> */
>> setImage(sy,sx,103,false);
>> playSound(0);
>> 
>> 
>> TTFN,
>> David
>> 
>> Systems Librarian, Louisiana Tech University
>> merchant at latech.edu
>> JavaScript List Administrator (www.mountaindragon.com/javascript/)
>> Webmaster, HTML Encyclopedia (www.mountaindragon.com/html/)
>> Webmaster, Memorial Day Page (www.usmemorialday.org/)
>> Webmaster, Midori Ito Site (www.mountaindragon.com/midori/)
> 
> 
> 
> 
> 
> 
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 




More information about the Javascript mailing list