I’m working on a project for school, and as a part of this project I would like the window to move to a random place onscreen if the mouse touches it. Yes, I know this can be annoying, but it will simply be a part of my project. Be gentle, I’m just learning JS. Thanks! ?
@CableauthorApr 30.2008 — #Thanks! That code makes sense to me so far. Where would I add a check to determine if the mouse is still on the window even after it moved, so as to move it again? I'd like the window to continuously check for the mouse, and if the mouse is touching it, it will move.
@CableauthorMay 08.2008 — #I would love to have the code if you wouldn't mind. I've been fiddling with it and can't get it to behave the way I'd like it to. Maybe I can learn a thing or two from your code. Yep, I'm a noob.
var currentElement = Event.element(evt); if (currentElement.className == "moveable") { var randomX = Math.floor(Math.random()*200); var randomY = Math.floor(Math.random()*200); self.moveTo(randomX,randomY);