chris_angell
09-25-2002, 06:10 PM
hello
I have written this code, but I want to change it, and the code you see below has already pushed my javascript skills to thier max.. so I seek help..
At the moment regarding the code below, The more you move your arrow to the left, the faster the animation rotates :) it tracks the x position.. but I am trying to get the animation to flash faster when the mouse it at x position 300, and y 20 pixels, but I am not to sure how to go about this, the code below works. and I hope you can adapt it.
thank you....
<SCRIPT LANGUAGE = "JavaScript">
imgNumber = 0;
totalimgNumber = 2;
anim = new Array();
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
function getMouseXY(e) {
if (IE) {
tempX = event.clientX + document.body.scrollLeft
} else {
tempX = e.pageX
}
}
for (i = 0; i < totalimgNumber; i++) {
anim[i] = new Image (239, 390);
anim[i].src = 'images/_navigationarrow' + (i + 1) + '.gif';
}
function Switch() {
document.randimg.src = anim[imgNumber].src;
imgNumber++;
if(imgNumber >= totalimgNumber) imgNumber = 0;
}
function animate() {
Switch();
setTimeout("animate()", tempX);
}
</SCRIPT>
</head>
<body onLoad = "animate()"">
<div id="navigationarrowDiv">
<img name="randimg" id="robot" src="images/_navigationarrow1.gif" width="71" height="73"></div>
:) chris
I have written this code, but I want to change it, and the code you see below has already pushed my javascript skills to thier max.. so I seek help..
At the moment regarding the code below, The more you move your arrow to the left, the faster the animation rotates :) it tracks the x position.. but I am trying to get the animation to flash faster when the mouse it at x position 300, and y 20 pixels, but I am not to sure how to go about this, the code below works. and I hope you can adapt it.
thank you....
<SCRIPT LANGUAGE = "JavaScript">
imgNumber = 0;
totalimgNumber = 2;
anim = new Array();
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
function getMouseXY(e) {
if (IE) {
tempX = event.clientX + document.body.scrollLeft
} else {
tempX = e.pageX
}
}
for (i = 0; i < totalimgNumber; i++) {
anim[i] = new Image (239, 390);
anim[i].src = 'images/_navigationarrow' + (i + 1) + '.gif';
}
function Switch() {
document.randimg.src = anim[imgNumber].src;
imgNumber++;
if(imgNumber >= totalimgNumber) imgNumber = 0;
}
function animate() {
Switch();
setTimeout("animate()", tempX);
}
</SCRIPT>
</head>
<body onLoad = "animate()"">
<div id="navigationarrowDiv">
<img name="randimg" id="robot" src="images/_navigationarrow1.gif" width="71" height="73"></div>
:) chris