RelaXx: objecte mehrfach erstellen

Beitrag lesen

mein problem ist das ich das object "unit" nicht nicht mehrmals erstellen kann.
bei "base_object2" von dem "unit" erbt geht das noch.
ich vermute den fehler im constructor von "unit" komm aber nicht drauf...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
<html>  
  <head>  
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">  
  <meta name="generator" content="PSPad editor, www.pspad.com">  
  <title></title>  
  </head>  
  
  
  <body>  
<div id="map">  
  
</div>  
  </body>  
 [code lang=javascript] <script type="text/javascript">  
  
var mapbox ='map';  
  
function base_object2()  
{  
  
this.div = document.createElement("div");  
this.div.id = 0;  
this.div.style.top = 0+ "px";  
this.div.style.left = 0+ "px";  
this.div.innerHTML=0;  
this.init_div=init_div;  
//this.type=type;  
this.update=0;  
this.status=0;  
this.action=0;  
}  
function init_div()  
{  
document.getElementById(mapbox).appendChild(this.div);  
}  
function move_to(x,y)  
{  
this.div.style.top=x+ "px";  
this.div.style.left=y+ "px";  
}  
function move_relative (x,y)  
{  
this.div.style.top=x+ "px";  
this.div.style.left=y+ "px";  
}  
  
function unit(id,x,y,html,update,status,action)  
{  
//this.constructor =  base_object2();  
this.div.id = id;  
this.div.style.top = x+ "px";  
this.div.style.left = y+ "px";  
this.div.innerHTML=html;  
this.move_to=move_to;  
}  
unit.prototype = new base_object2;  
  
//    zwei base_object2 instanzierungen funktionieren  
test1= new base_object2;  
test1.init_div();  
test2= new base_object2;  
test2.div.style.top = 20+ "px";  
test2.init_div();  
  
//        aber 2 unit instanzierungen nicht  
heinz = new unit('iiiiiiiiiiiii',190,550,'house','eaga','50;6',null) ;  
heinz.init_div();  
heinz.move_to(300,300);  
heinz1 = new unit('uuuuuuuuuu',20,20,'house','eaga','50;6',null) ;  
heinz1.init_div();  
  
  </script>

</html>[/code]
schon mal danke für eure hilfe im vorraus!

mfg
RelaXx