Cross-Platform DHTML Moving Tractor
At 0440 PM 5/3/99 -0400, J14j99@aol.com wrote
>I have this truck.gif and I want the truck to go from right to left and
>repeat that continually so I wrote this code below. But all the truck does is
>sits there and does nothing(like a few of my relatives!). I've been nawing on
>it for days and I can't find out what went wrong. You can see the code below
>or @ http//members.aol.com/J14j99/truck.htm. Thanks for any help or advice.
Jordan,
There were several different things wrong with your code, the largest of
which was that you didn't have anything that initiated the setTimeout()
loop. You need a call, either in the script tag or in an onLoad event
handler, to the goTruck() function to start that off.
Instead of going through the changes, I've posted a version that works in
NS4 and IE4+ in my workshop at
http//www.serve.com/apg/workshop/dhtmlTractor/
I also added a stop and start button so that you can see how that would
work. In playing with the buttons I noticed a cool side effect that I hadn't
planned on Clicking the "Gas" button multiple times will actually cause the
tractor to go faster and faster. You can then slow it down to a stop by
repeatedly clicking the "Brakes" button.
Hope this helps. :)
- Porter
Back to my workshop.