Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need some fresh eyes to look for error

Status
Not open for further replies.

theEclipse

Programmer
Dec 27, 1999
1,190
US
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>
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;<br>
&lt;HTML&gt;<br>
&lt;HEAD&gt;<br>
&lt;TITLE&gt;&lt;/TITLE&gt;<br>
&lt;script language=&quot;javascript&quot;&gt;<br>
var numsteps = 121;<br>
var timer<br>
<br>
function construct(div,endx,endy){<br>
this.all=(document.all)?document.all[div].style:(document.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>
&lt;/script&gt;<br>
&lt;style&gt;<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>
&lt;/style&gt;<br>
&lt;/HEAD&gt;<br>
&lt;body onload=&quot;startIt()&quot; background=&quot;images/background.gif&quot; id=body scroll=no text=#ffffff bgproperties=fixed&gt;<br>
&lt;div id=PlanetAndMoon style=&quot;position:absolute; top:-15; left:-240;&quot;&gt;<br>
This is the div that moves from a random location to a defined location.&lt;/div&gt;<br>
&lt;/BODY&gt;<br>
&lt;/HTML&gt;<br>
<br>
thanks in advance, <p>theEclipse<br><a href=mailto: > </a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top