...

View Full Version : Image Trouble



Insanity Inc
07-11-2003, 05:35 PM
I am trying to create a script that will rotate an image around a central logo. This is what I have...

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script>
function SpinImage(ImageID, InitAng)
{
xPos = Math.cos(InitAng) * 180;
xPos = xPos + 385;
document.getElementById(ImageID).style.pixelLeft = xPos;
yPos = Math.sin(InitAng) * 180;
yPos = yPos + 185;
document.getElementById(ImageID).style.pixelTop = yPos;
InitAng = InitAng + 0.01;
SpinTimer=setTimeout("SpinImage()", 90);
}
</script>
<title>
</title>

</head>
<body>
<img src="untitled.bmp" name="Image1" onLoad="SpinImage("Image1", 1.4273)" style="position:absolute;"></img>

</body>

</html>

Thanks for any help

Vladdy
07-11-2003, 05:38 PM
http://www.codingforums.com/showthread.php?s=&threadid=22357
should help

Insanity Inc
07-11-2003, 06:07 PM
it didn't... i can;t read that well

and it goes in an ellipse

Vladdy
07-11-2003, 06:11 PM
circle is an ellipse with zero distance beween focal points...
In my script set radii to the same value and it will move in circle

Insanity Inc
07-11-2003, 06:23 PM
yes i understand geometry... lol sorry its been a long day

i wrote this script over a year ago and lost it today, and i'm trying to get it back.

Now what i had in should work, it is almost exactly what you wrote. I can't read through that well though, I write code more spaced out so I can read it easier...

the computer has been giving me stupid errors like "out of memory" and things like that when i run the code. right now it wants a ")" where there already is one...

currently the code is:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
</title>
</head>
<body>
<div id="image1" style="position:absolute;" onLoad="SpinImage("image1",0)">
<img src = "image.jpg">
</div>
<script>
var xPos;
var yPos;

function SpinImage(ImageID, InitAng)
{
xPos = Math.cos(InitAng) * 180;
xPos = xPos + 385;
document.getElementById(ImageID).style.pixelLeft = xPos + "px";
yPos = Math.sin(InitAng) * 180;
yPos = yPos + 185;
document.getElementById(ImageID).style.pixelTop = yPos + "px";
InitAng = InitAng + 0.01;
SpinTimer=setTimeout("SpinImage("image1", InitAng)", 90);
}
</script>


</body>
</html>

It says it is missing a parentheses in the timer line... can you help with that?

Vladdy
07-11-2003, 06:44 PM
Mine are red

Originally posted by Insanity Inc
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">All new documents should really be Strict compliant
<html>
<head>
<title>
</title>
</head>
<body>
<div id="image1" style="position:absolute;" onLoad="SpinImage("image1",0)"> div element does not have onload event, just body (and a few other elements, which are out of scope of this discussion)
<img src = "image.jpg">
</div>
<script>
var xPos;
var yPos;

function SpinImage(ImageID, InitAng)
{
xPos = Math.cos(InitAng) * 180;
xPos = xPos + 385;
document.getElementById(ImageID).style.pixelLeft = xPos + "px"; pixelLeft is not part of style
yPos = Math.sin(InitAng) * 180;
yPos = yPos + 185;
document.getElementById(ImageID).style.pixelTop = yPos + "px";nor is pixelTop
InitAng = InitAng + 0.01;
SpinTimer=setTimeout("SpinImage("image1", InitAng)", 90);Watch for nested qoutes
}
</script>


</body>
</html>

Insanity Inc
07-11-2003, 07:23 PM
thanks... so what would I use to load, and how to set the values then, as well as fix the quotes



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum