Results 1 to 3 of 3
Thread: [JS] while button pressed?
-
November 27th, 2005, 07:54 PM #1
[JS] while button pressed?
How do you make a loop (while) in javascript which is active while a certain link/button/image is pressed?
got pwnt?
-
November 27th, 2005, 08:15 PM #2To make this work on any element, eg. an "<img .. />" element, you just have to copy the event code: `onmousedown="startLoop(1);" onmouseup="endLoop();"`HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>i©io -> .harish</title> <style type="text/css">body { font-family:"Trebuchet MS"; }</style> <script type="text/javascript"> // *********************************************** var loop = false; var increment = 1; var scrollTop = 0; function startLoop(change) { increment = change; loop = true; loopMe(); } function endLoop() { loop = false; } function loopMe() { if (!loop) { return; } scrollTop += increment; document.title = scrollTop; setTimeout(loopMe, 100); } // *********************************************** </script> </head> <body> <a onmousedown="startLoop(1);" onmouseup="endLoop();">Increase</a><br /> <a onmousedown="startLoop(-1);" onmouseup="endLoop();">Decrease</a> </body> </html>
Hope this helps
"60% of the time it works... every time." -- Paul Rudd as Brian Fantana.
-
November 27th, 2005, 08:35 PM #3
i hate you
got pwnt?
Similar Threads
-
just need to run a test to see which button was pressed!! how?
By kyle_davis13 in forum ActionScript 2 (and Earlier)Replies: 20Last Post: February 15th, 2007, 07:07 AM -
button isnt working ( external .swf thing )
By doOfus in forum Flash IDEReplies: 3Last Post: January 2nd, 2004, 08:31 PM -
measure how long button (or clip!) is pressed for
By joecastro in forum ActionScript 2 (and Earlier)Replies: 4Last Post: December 28th, 2003, 10:29 AM -
Controlling movieclips with an IF function
By w9914420 in forum ActionScript 2 (and Earlier)Replies: 5Last Post: December 6th, 2003, 09:39 PM -
How do I detect which button has been pressed?
By yorkshirepuddin in forum ActionScript 2 (and Earlier)Replies: 6Last Post: November 30th, 2002, 06:31 PM

Reply With Quote
Bookmarks