Comunidad de diseño web y desarrollo en internet online

ESto no me chuta ¿por que?

Citar            
MensajeEscrito el 06 Ago 2005 01:22 am
Hola, estaba probando esta pedazo funcion(no os asusteis por favor que hasta yo entiendo algo) y lo cierto es que al ejecutarla con el depurador las variables shapeX y shapeY aparece como undefined cuando tendrian que ser numeros(creo), he probado a usar esto

Código :

this.shapeX=new Number
   this.shapeY=new Number

pero continua igual, no se que puede estar mal
¿Alguien lo sabe?


Código :

fly = function () {
   this.shapeX=new Number
   this.shapeY=new Number
   this._xscale = 30;
   this._yscale = 30;
   this.shapeX = this._x;
   this.shapeY = this._y;
   this.targetX = 0;
   this.targetY = 0;
   this.oldTargetX = 0;
   this.flockX = (Math.random()*200)-100;
   this.flockY = (Math.random()*200)-100;
   // Crear el script onEnterFrame para animar _parent
   this.onEnterFrame = function() {
      // posicion del raton y distancia de este
      this.targetX = _root._xmouse;
      this.targetY = _root._ymouse;
      this.distX = this.targetX-this.shapeX+this.flockX;
      this.distY = this.targetY-this.shapeY+this.flockY;
      if ((this.targetX == this.oldTargetX) && Math.random()>0.9) {
         // si el raton esta quieto el grupo se hace mas compacto
         this.flockX = (Math.random()*200)-50;
         this.flockY = (Math.random()*200)-50;
      } else if ((this.targetX != this.oldTargetX) && Math.random()>0.8) {
         // Si el raton esta quieto la nube ocupa mayor espacio
         this.flockX = (Math.random()*400)-200;
         this.flockY = (Math.random()*400)-200;
      }
      // Aplicar la ecuacion de inercia
      this.shapeX = (this.shapeX+(this.distX/20));
      this.shapeY = (this.shapeY+(this.distY/20));
      // realizar la animacion
      this._x = this.shapeX;
      this._y = this.shapeY;
      // recordar ultima posicion del raton para decidir
      this.oldTargetX = this.targetX;
   };
};
for (i=0; i<20; i++) {
   _root.attachMovie("bug", "bug"+i, i);
   fly.apply(_root["bug"+i]);
}

Por neoarcangel

39 de clabLevel



 

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:27 am
es:

Código :

new Number();

porque estas creando un objeto numero no una variable :wink:
y te recomendaria que lo pusieras asi:

Código :

this.shapeX:Number = new Number();

:D

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:34 am
Si lo pongo asi

Código :

this.shapeX=new Number()
   this.shapeY=new Number()


no funciona pero no da ningun tipo de error sin embargo si lo pongo como me has dicho, es decir

Código :

this.shapeX:Number=new Number()
   this.shapeY:Number=new Number()


Sale esto

Código :

**Error** Símbolo=swarm, capa=AS, fotograma=1:Línea 41: Error de sintaxis.
        this.shapeX:Number=new Number()

**Error** Símbolo=swarm, capa=AS, fotograma=1:Línea 42: Error de sintaxis.
        this.shapeY:Number=new Number()

Total de errores de ActionScript: 2     Errores comunicados: 2


De todos modos ese metodo que dices el de ":Number" tambien lo habia probado en otro ejercicio y me siguio dando error y en configuracion de publicacion lo esta ejecutando bajo flash 7 y AS2.
¿Que puede fallar?

Por neoarcangel

39 de clabLevel



 

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:36 am
te falta los puntos y comas :roll:

;

entendiste :P

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:39 am
Ni aun asi mira

Código :

**Error** Símbolo=swarm, capa=AS, fotograma=1:Línea 41: Error de sintaxis.
        this.shapeX:Number = new Number();

**Error** Símbolo=swarm, capa=AS, fotograma=1:Línea 42: Error de sintaxis.
        this.shapeY:Number = new Number();

Total de errores de ActionScript: 2     Errores comunicados: 2

siguen undefined las variables

Por neoarcangel

39 de clabLevel



 

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:40 am
shapeX y shapeY es alguna propiedad de algun objeto de Flash? :?

si es asi no puedes hacerlo :roll:

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:44 am
oh crap se me escapaba algo, lo siento necesitan de prefijo var, asi:

Código :

var shapeX:Number = new Number();


debes quitarle el this alli :wink:

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab



Ultima edición por Maikel el 06 Ago 2005 01:45 am, editado 1 vez

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:45 am
No no shapeX y shapeY, son variables que contienen la inercia del objeto, pero no son propiedades, lo se de seguro por que de donde he sacado esa funcion anteriormente habia un ejercicio algo menos complicado que usaba la misma variable, guarda esto

Código :

this.shapeX = (this.shapeX+(this.distX/20));
      this.shapeY = (this.shapeY+(this.distY/20));

Por neoarcangel

39 de clabLevel



 

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:46 am
lee arriba de tu último post :wink:

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:49 am
no funciona ni con var, y lo he probado asi

Código :

var shapeX = new Number();
var shapeY = new Number();


asi

Código :

var shapeX:Number= new Number();
var shapeY:Number = new Number();


asi

Código :

var this.shapeX = new Number();
var this.shapeY = new Number();


y asi


Código :

var this.shapeX:Number = new Number();
var this.shapeY:Number = new Number();



el this lo pongo por que es una funcion que usa apply y creo que es necesario

no funciona pero al menos hemos solventado el hecho de que diese error, algo es algo

Por neoarcangel

39 de clabLevel



 

firefox
Citar            
MensajeEscrito el 06 Ago 2005 01:52 am
cuentame algo shapeX se ve en color azul en el editor de flash? :?

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 06 Ago 2005 02:02 am
No, no se ve en azul se ve en negro, este es el archivo por si quieres probarlo



http://es.geocities.com/rockmanandzero/Abejas.zip

Por neoarcangel

39 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.