i have this assignment for class i was wondering if anyone could give me a hint on how to complete it:
*)Display an image of a robot near the left side of a web page. The image can be any graphics file you find on the web or create yourself. May I suggest one of the cool Android mascots from the last Google I/O conference.
Display a Start button on the page.
When the Start button is clicked:
the robot shall start moving to the right.
the Start button shall become a Stop button.
When the Stop button is clicked:
the robot shall stop moving.
the Stop button shall become a Start button.
The Start/Stop button shall work repeatedly.
After the robot exits on the right, it shall re-enter from the left. Suggestion: To support all browsers, use the screen width rather than the window width. *)
I really need help getting the image to move and stop and move back with the button. If anyone could help it would be great.
function doMove() {
robot.style.left = parseInt(robot.style.left)+1+'px';
setTimeout(doMove,20); // call doMove in 20msec
}
function init() {
robot = document.getElementById('robotObject'); // get the "robot" object
robot.style.left = '0px'; // set its initial position to 0px
doMove(); // start animating
}
Bookmarks