wer kann mir aus diesem Schlamassel heraus helfen?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>opdracht 2b</title>
<script type="text/javascript">
function init(){
Rect1 = new startAnimation("rect1","yellow",0,0,2);
Rect2 = new startAnimation("rect2","red",20,20,3);
Rect3 = new startAnimation("rect3","blue",40,40,4);
Rect4 = new startAnimation("rect4","green",80,80,5);
Rect5 = new startAnimation("rect5","#0033cc",0,200,6);
Rect6 = new startAnimation("rect6","#00ff00",20,100,7);
Rect7 = new startAnimation("rect7","#330066",200,0,8);
Rect8 = new startAnimation("rect8","#996600",130,100,9);
setInterval(goRect,40);
}
function goRect()
{
Rect1.animateGo(Rect1.getRect());
Rect2.animateGo(Rect2.getRect());
Rect3.animateGo(Rect3.getRect());
Rect4.animateGo(Rect4.getRect());
Rect5.animateGo(Rect5.getRect());
Rect6.animateGo(Rect6.getRect());
Rect7.animateGo(Rect7.getRect());
Rect8.animateGo(Rect8.getRect());
}
function startAnimation(rect, color, STop, SLeft, zIndex){
getObj(rect).style.background = color;
getObj(rect).style.top = STop + "px";
getObj(rect).style.left = SLeft + "px";
getObj(rect).style.zIndex = zIndex;
this.rect = rect;
var xTempo = 5;
var yTempo = 5;
var x;
var y;
this.getRect = function()
{
return this.rect;
}
this.animateGo = function(rect)
{
if(x >= (getObj("box").offsetWidth-getObj(rect).offsetWidth)){
xTempo = -5;
}
if(x <= 0){
xTempo = 5;
}
if(y >= (getObj("box").offsetHeight-getObj(rect).offsetHeight)){
yTempo = -5;
}
if(y <= 0){
yTempo = 5;
}
x = getObj(rect).style.left + xTempo;
y = getObj(rect).style.top + yTempo;
getObj(rect).style.left = x + "px";
getObj(rect).style.top = y + "px";
}
}
function getObj(elementID){
return document.getElementById(elementID);
}
</script>
<style type="text/css">
#box { position: absolute; top: 50px; background: navy; height: 300px; width: 400px; z-index: 1; }
#rect1 { position: absolute; height: 20px; width: 20px; }
#rect2 { position: absolute; height: 20px; width: 20px; }
#rect3 { position: absolute; height: 20px; width: 20px; }
#rect4 { position: absolute; height: 20px; width: 20px; }
#rect5 { position: absolute; height: 20px; width: 20px; }
#rect6 { position: absolute; height: 20px; width: 20px; }
#rect7 { position: absolute; height: 20px; width: 20px; }
#rect8 { position: absolute; height: 20px; width: 20px; }
</style>
</head>
<body>
<div id="box">
<div id="rect1"></div>
<div id="rect2"></div>
<div id="rect3"></div>
<div id="rect4"></div>
<div id="rect5"></div>
<div id="rect6"></div>
<div id="rect7"></div>
<div id="rect8"></div>
</div>
<a href="java script:init()">Start</a>
</body>
</html>

Hilfe
Neues Thema
Antworten


Nach oben


