Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/12/2013, 16:35
Avatar de patilanz
patilanz
 
Fecha de Ingreso: enero-2012
Mensajes: 880
Antigüedad: 13 años, 2 meses
Puntos: 29
Acceder al objeto padre (no es DOM)

Hola estoy creando unos objetos:

Código Javascript:
Ver original
  1. var pj=function(name,type,arm...){
  2.     this.name=name;
  3.     this.width=width||20;
  4. ...
  5.  
  6. }
  7.  
  8. pj.prototype.draw=function(x,y,width,height,rotate){
  9.     width=width||this.width;
  10.     height=height||this.height;
  11.     rotate=rotate||this.rotate;
  12.    
  13.     c.save();
  14.     c.setTransform(1,0,0,1,0,0);
  15.     c.translate(x+.5*width,y+.5*height);
  16.     c.rotate(rotate*Math.PI/180);
  17. ...
  18. }
  19.  
  20. //Parte importante
  21. pj.prototype.animation={
  22.     made:function(animation){
  23.         console.log(animation.x);
  24.         animation.eyesUp={
  25.             change:'y',
  26.             llegar:function(){
  27.                 //console.log(animation);
  28.             }
  29.         }
  30.     }
  31. };

En el objeto animation de pj quiero acceder desde made hasta pj. Osea desde el objeto made de animation de pj hasta pj, el padre supongo ...

He probado con hacer una function auto ejecutable para pasar le como argumento el this pero no funciona. Alguna idea?

Saludo