Sorry, If I don't post this here, I'l lose it...
<HTML><!-- Thread on Javascript: http://www.ozoneasylum.com/Forum2/HTML/001712.html -->
<HEAD>
<TITLE>Acceleration-Deceleration (08.14.02)</TITLE>
<STYLE type="text/css">
BODY{background-color:#000000;color:#FC6203;}
H1{color:#FF8800;font-size:18px;}
input {margin: 2px;background-color:#999999;color:#FFFFFF}
form {position:absolute;top:3;left:400}
.floatie{font-size:24px;color:#3366FF;}
#castle{position:absolute;font-size:35px;color:#3366FF;top:100;left:150;}
</STYLE>
<SCRIPT language="Javascript">
//Code by Voodoo 'Doll' Petskull
//petskull@nospam.twistedport.com
//http://www.twistedport.com
var newLeft = 0;
var newTop = 0;
var lastLeft = 0;
var lastTop = 0;
function mousetrack(){ //Print out where the mouse is-
daForm.mousetracker2000left.value = event.clientX;
daForm.mousetracker2000top.value = event.clientY;
}
function moveThing(){ //Move the layer 'castle'--
// make all the *old* click vars old and all the *new* click vars new
// and input it in the status bar
lastLeft = newLeft;
lastTop = newTop;
newLeft = event.clientX;
newTop = event.clientY;
window.status= "New Location-- Left: "+newLeft+", Top: "+newTop+" Old Location-- Left: "+lastLeft+", Top: "+lastTop;
// -----------------------------------------/
// Now figure out the distance between the two- for left and for right.....
var disLeft = lastLeft - newLeft;
var disTop = lastTop - newTop;
window.status= "New Location-- Left: "+newLeft+", Top: "+newTop+" Old Location-- Left: "+lastLeft+", Top: "+lastTop+"-- Distance Between: Left: "+disLeft+", Top: "+disTop;
//------------------------------------------/
accdec(lastLeft,lastTop);
}
function accdec(amtleft,amttop){ //Accelerate-Decelerate depending on proximity--
castle.style.left = amtleft;
castle.style.top = amttop;
return(this);
}
</SCRIPT>
</HEAD>
<BODY ONMOUSEMOVE="mousetrack();" ONMOUSEDOWN="moveThing();">
<H1>Hello, World!</H1>
In this daring episode, I will try to make objects move in nifty ways.<BR>
For example, acceleration & deceleration.
<FORM ID="daForm">
<INPUT name="mousetracker2000left" type="text" READONLY="yes" VALUE="left nuthin'...">
<INPUT name="mousetracker2000top" type="text" READONLY="yes" VALUE="top nuthin'..."><BR>
LEFT &n bsp; TOP
</FORM>
<DIV ID="castle">
<TABLE CLASS="floatie" bgcolor=#3366FF width=30 height=30 border=0 cellpadding=0 cellspacing=1>
<TR><TD bgcolor=#000000 cellspacing=1 cellpadding=0 align=center valign=middle>¤</TD></TR>
</TABLE>
</DIV>
</BODY>
</HTML>
Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342