Ver Mensaje Individual
  #9 (permalink)  
Antiguo 16/11/2009, 21:03
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años, 8 meses
Puntos: 834
Respuesta: ¿Como apunto un elemento desde una variable de un objeto?

Sólo apuntar que los setters y getters sí existen (vía los métodos mágicos __defineGetter__ y __defineSetter__ o los operadores set y get), pero el querido explorer no los soporta, así que ajo y agua.
De todas maneras dejo un ejemplo y un par de enlaces:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title></title>
<
script>
function 
circle(radiopositionXpositionY)
{
    
    
this.ra radio;
    
this.di radio*2;
    
this.element document.body.appendChild(document.createElement("div"));
    
this.element.style.position "absolute";
    
this.element.style.left positionX+"px";
    
this.element.style.top positionY+"px";
    
this.element.style.width radio*2+"px";
    
this.element.style.height radio*2+"px";
    
this.element.style.backgroundColor "#000";
}
try{
    
circle.prototype={set posX (x){this.element.style.left=x+'px';}}//operador 
    
circle.prototype.__defineSetter__('posY',function(x){this.element.style.top=x+'px';});//método mágico
}catch(e){
    
alert('soy explorer');
}
onload=function(){
var 
c=new circle(501010);
c.posX=500;
c.posY=200;
}
</script>
</head>

<body>
</body>
</html> 
http://www.robertnyman.com/javascrip...rs-and-setters
https://developer.mozilla.org/en/Cor...rs_and_Setters