theEclipse
Programmer
I have a problem with one of my scripts, and cant seem to figure out what the problem is. Maybee I just need some fresh eyes to look at the code.<br>
<br>
The script, enclosed at the end of my post, is supposed to take in a div, and ending variables for the top, and left.<br>
it then calculates(, or stores in this case) a step value to the stepx, and stepy variables of the object.<br>
<br>
I think my problem is in the setTimeout line of the movement function, which I have marked.<br>
<br>
Thanks for your help.<br>
<br>
file, index2-1.html:<br>
<br>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br>
<HTML><br>
<HEAD><br>
<TITLE></TITLE><br>
<script language="javascript"><br>
var numsteps = 121;<br>
var timer<br>
<br>
function construct(div,endx,endy){<br>
this.all=(document.all)?document.all[div].styledocument.layers)?document.layers[div]:null;<br>
this.left=this.all.pixelLeft;<br>
this.top=this.all.pixelTop;<br>
this.visibility=this.all.visibility;<br>
this.calcStep=calculateNumSteps;<br>
this.mover=makeItMove;<br>
//this.stepMover=moveItWithSteps;<br>
this.stepx=0;<br>
this.stepy=0;<br>
this.endx=endx;<br>
this.endy=endy;<br>
this.steps=numsteps;<br>
this.initx=this.left;<br>
this.inity=this.top;<br>
}<br>
<br>
function startIt(){<br>
pntMon=new construct('PlanetAndMoon',245,15);<br>
pntMon.calcStep()<br>
moveItWithSteps(pntMon)<br>
}<br>
<br>
function calculateNumSteps(){<br>
<br>
//\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\the step calculator/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\\<br>
this.stepx=2.0354981<br>
this.stepy=1.3472023}<br>
<br>
function makeItMove(x,y){}<br>
<br>
function moveItWithSteps(object){<br>
object.left=this.left+this.stepx;<br>
object.top=this.top+this.stepy;<br>
<br>
//\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\this is where I think the problem is./\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\<br>
var timeoutStr='moveItWithSteps('+object.all+');'<br>
timer=setInterval(timeoutStr,50);<br>
}<br>
<br>
</script><br>
<style><br>
#hideLyr {position:absolute; top:0; left:0; width:110%; height:100%; background-color:#000000; layer-background-color:#000000; z-index:20000000000000000;}<br>
#centerHide {position:absolute; top:40%; left:35%; font-family:Comic Sans MS; color:#C0C000;}<br>
</style><br>
</HEAD><br>
<body onload="startIt()" background="images/background.gif" id=body scroll=no text=#ffffff bgproperties=fixed><br>
<div id=PlanetAndMoon style="position:absolute; top:-15; left:-240;"><br>
This is the div that moves from a random location to a defined location.</div><br>
</BODY><br>
</HTML><br>
<br>
thanks in advance, <p>theEclipse<br><a href=mailto: > </a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>
<br>
The script, enclosed at the end of my post, is supposed to take in a div, and ending variables for the top, and left.<br>
it then calculates(, or stores in this case) a step value to the stepx, and stepy variables of the object.<br>
<br>
I think my problem is in the setTimeout line of the movement function, which I have marked.<br>
<br>
Thanks for your help.<br>
<br>
file, index2-1.html:<br>
<br>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br>
<HTML><br>
<HEAD><br>
<TITLE></TITLE><br>
<script language="javascript"><br>
var numsteps = 121;<br>
var timer<br>
<br>
function construct(div,endx,endy){<br>
this.all=(document.all)?document.all[div].styledocument.layers)?document.layers[div]:null;<br>
this.left=this.all.pixelLeft;<br>
this.top=this.all.pixelTop;<br>
this.visibility=this.all.visibility;<br>
this.calcStep=calculateNumSteps;<br>
this.mover=makeItMove;<br>
//this.stepMover=moveItWithSteps;<br>
this.stepx=0;<br>
this.stepy=0;<br>
this.endx=endx;<br>
this.endy=endy;<br>
this.steps=numsteps;<br>
this.initx=this.left;<br>
this.inity=this.top;<br>
}<br>
<br>
function startIt(){<br>
pntMon=new construct('PlanetAndMoon',245,15);<br>
pntMon.calcStep()<br>
moveItWithSteps(pntMon)<br>
}<br>
<br>
function calculateNumSteps(){<br>
<br>
//\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\the step calculator/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\\<br>
this.stepx=2.0354981<br>
this.stepy=1.3472023}<br>
<br>
function makeItMove(x,y){}<br>
<br>
function moveItWithSteps(object){<br>
object.left=this.left+this.stepx;<br>
object.top=this.top+this.stepy;<br>
<br>
//\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\this is where I think the problem is./\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\<br>
var timeoutStr='moveItWithSteps('+object.all+');'<br>
timer=setInterval(timeoutStr,50);<br>
}<br>
<br>
</script><br>
<style><br>
#hideLyr {position:absolute; top:0; left:0; width:110%; height:100%; background-color:#000000; layer-background-color:#000000; z-index:20000000000000000;}<br>
#centerHide {position:absolute; top:40%; left:35%; font-family:Comic Sans MS; color:#C0C000;}<br>
</style><br>
</HEAD><br>
<body onload="startIt()" background="images/background.gif" id=body scroll=no text=#ffffff bgproperties=fixed><br>
<div id=PlanetAndMoon style="position:absolute; top:-15; left:-240;"><br>
This is the div that moves from a random location to a defined location.</div><br>
</BODY><br>
</HTML><br>
<br>
thanks in advance, <p>theEclipse<br><a href=mailto: > </a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>