Comunidad de diseño web y desarrollo en internet online

Ayuda, paso de AS1 a AS2

Citar            
MensajeEscrito el 04 Ago 2008 05:30 am
Hola, bueno.., la cosa es que me doy mania con esto pero...algunas cosas no llego, tengo un AS para hacer un menu Tzunami, pero al pasarlo a AS2 ahi unos caracteres que cambian, tonces me tira error, antes sabia cales cambiaban..pero hacia rato k no me metia con un archivito viejo..:P... ahi va el codigo
El error me lo tira en la linea 14 y 19..que serian estas

14: set("textY" add i, getProperty ("text" add i, _y ) );

19: }

por las dudas posteo el codigo entero, bueno...desde ya mil gracias. Saludos!!


Código :

colnum = "1";
startnum = 1;
endnum = 19;
numberofItems = 19;
mouseposX = int(getProperty("../dragscale", _x));
mouseposY = int(getProperty("../dragscale", _y));
i = startnum;
m = startnum;
filledSpace = 0;
gapspace = 0;
if (Number(myInit) == Number(FALSE)) {
   // on first run make an array of all the text Y Pos.
   while (Number(i)<=Number(endnum)) {
      set("textY" add i, getProperty ("text" add i, _y ) );
      i = Number(i)+1;
   }
   i = startnum;
   myInit = TRUE;
}
boundleft = getProperty ("../boundbox" add colnum, _x);
boundright = boundleft + getProperty ("../boundbox" add colnum, _width) ;
boundtop =  getProperty ("../boundbox" add colnum, _y);
boundbottom = boundtop + getProperty ("../boundbox" add colnum,_height);
if (Number(mouseposX)>=Number(boundleft) and Number(mouseposX)<=Number(boundright) and Number(mouseposY)>=Number(boundtop) and Number(mouseposY)<=Number(boundbottom)) {
   while (Number(i)<=Number(endnum)) {
      myDif = (eval("textY" add i) ) - (mouseposY - boundtop);
      // percentage increase
      scaleAmount = 250-((myDif*myDif)/16);
      alphaAmount = 100-((myDif*myDif)/6);
      if (Number(alphaAmount)<50) {
         alphaAmount = 50;
      }
      if (Number(scaleAmount)<100) {
         scaleAmount = 100;
      }
      setProperty("text" add i, _xscale, scaleAmount);
      setProperty("text" add i, _yscale, scaleAmount);
      setProperty("text" add i, _alpha, alphaAmount);
      i = Number(i)+1;
   }
   // *** add up total Y pixels taken by text ***
   while (Number(m)<=Number(endnum-1)) {
      filledSpace = filledspace + getProperty ( "text" add m, _height);
      m = Number(m)+1;
   }
   // *** find total Y pixels not taken by text
   totalheight = getProperty ( "text" add endnum, _y) - getProperty ( "text" add startnum, _y);
   gapSpace = totalheight-filledspace;
   avgDistance = gapSpace/numberofitems;
   m = Number(startnum)+1;
   while (Number(m)<=Number(endnum-1)) {
      setProperty("text" add m, _y, (getProperty ( "text" add (m-1), _y) + getProperty ( "text" add (m-1), _height)) + avgdistance);
      set("watchheight" add m, getProperty ( "text" add m, _height));
      m = Number(m)+1;
   }
} else {
   // *** shrink text back when mouse rolls out
   i = startnum;
   while (Number(i)<=Number(endnum)) {
      if (int ( getProperty ("text" add i, _yscale ) ) >= 100) {
         // return scale back to original state
         setProperty("text" add i, _yscale, int ( getProperty ("text" add i, _xscale ) ) - 1);
         setProperty("text" add i, _xscale, int ( getProperty ("text" add i, _yscale ) ) -1);
      }
      if ( getProperty ("text" add i, _y) < eval("textY" add i)) {
         // return y position back to original state
         setProperty("text" add i, _y, int ( getProperty ("text" add i, _y ) ) + 1);
      }
      if ( getProperty ("text" add i, _y) > eval("textY" add i)) {
         setProperty("text" add i, _y, int ( getProperty ("text" add i, _y ) ) - 1);
      }
      if ( getProperty ("text" add i, _Alpha) > 50) {
         setProperty("text" add i, _alpha, int ( getProperty ("text" add i, _alpha ) ) - 1);
      }
      i = Number(i)+1;
   }
}

Por buffy299

26 de clabLevel



 

msie
Citar            
MensajeEscrito el 04 Ago 2008 09:24 am
Buaf... no eran solo dos líneas, cuando arreglas esas dos salen dos más y después de esas 3 y así continuamente, faltó poco para que me cansara, aquí tienes todo el código en AS2, no se realmente que es lo que hace porque dices que es un menú pero no veo donde se crean los textos y se le asigna formato, pero bueno, solamente lo que hice fue traducirlo:

Código :

var colnum:Number = 1;
var startnum:Number = 1;
var endnum:Number = 19;
var numberofItems:Number = 19;
var mouseposX:Number = Math.floor(this.dragscale._x);
var mouseposY:Number =  Math.floor(this.dragscale._y);
var i:Number = startnum;
var m:Number = startnum;
var filledSpace:Number = 0;
var gapspace:Number = 0;

if (!myInit) {
   // on first run make an array of all the text Y Pos.
   while (i <= endnum) {
      
      this["textY" + i] = this["text" + i]._y;

      i++;
   }
   
   i = startnum;
   
   myInit = true;
}

var boundleft:Number = this["boundbox" + column]._x;
var boundright:Number = boundleft + this["boundbox" + colnum]._width;
var boundtop:Number =  this["boundbox" + colnum]._y;
var boundbottom:Number = boundtop + this["boundbox" + colnum]._height;

var myDif:Number;
var scaleAmount:Number;
var avgDistance:Number;

if (mouseposX >= boundleft && mouseposX <= boundright && mouseposY >= boundtop && mouseposY <= boundbottom) {
   
   while ( i <= endnum) {
      
      myDif = this["textY" + i] - mouseposY - boundtop;
     
      // percentage increase     
      scaleAmount = 250- (myDif * myDif) / 16;
      alphaAmount = 100- (myDif * myDif) / 6;
     
      if (alphaAmount < 50) {
         alphaAmount = 50;
      }
      if (scaleAmount < 100) {
         scaleAmount = 100;
      }
     
     this["text" + i]._xscale = scaleAmount;
     this["text" + i]._yscale = scaleAmount;
     this["text" + i]._alpha = alphaAmount;
      i++;
   }
   
   // *** add up total Y pixels taken by text ***
   while (m <= endnum-1) {
      filledSpace += this["text" + m]._height;
      m++;
   }
   
   // *** find total Y pixels not taken by text
   totalheight = this["text" + endnum]._y - this["text" + startnum]._y;
   gapSpace = totalheight - filledspace;
   avgDistance = gapSpace / numberofitems;
   m = startnum + 1;
   
   while ( m <= endnum-1) {
      this["text" + m]._y = this["text" + (m-1)]._y + this["text" + (m-1)]._height + avgdistance;
      this["watchheight" + m] = this["text" + m]._height;
      m++;
   }
   
} else {
   
   // *** shrink text back when mouse rolls out
   i = startnum;
   
   while (i <= endnum) {
      
      if (Math.floor (this["text" + i]._yscale) >= 100) {
        
         // return scale back to original state
        this["text" + i]._yscale = Math.floor(this["text" + i]._xscale) - 1;
        this["text" + i]._xscale = Math.floor(this["text" + i]._yscale) - 1;
      }
     
      if (this["text" + i]._y < this["textY" + i]) {
        
         // return y position back to original state
        this["text" + i]._y = Math.floor(this["text" + i]._y) + 1;
      }
     
      if (this["text" + i]._y > this["textY" + i]) {
        
        this["text" + i]._y = Math.floor(this["text" + i]._y) - 1;
      }
     
      if (this["text" + i]._alpha > 50) {
        
        this["text" + i]._alpha = Math.floor(this["text" + i]._alpha) - 1;
      }
      i++;
   }
}


No lo copies y lo pegues, ve mirando línea por línea lo que ha cambiado para que lo aprendas, si lo copias solamente cuando te encuentres con otro problema similar no sabrás resolverlo.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 04 Ago 2008 09:42 am
muchas gracias, es una parte del menu, si anda bien lo subo para k lo vean. Saludos y gracias

Por buffy299

26 de clabLevel



 

msie
Citar            
MensajeEscrito el 04 Ago 2008 10:28 am

Por buffy299

26 de clabLevel



 

msie
Citar            
MensajeEscrito el 04 Ago 2008 10:49 am
Si tienes razón, todas las referencias que decían:

Código :

../unMovie


debían ser

Código :

this._parent.unMovie


Solamente cambia estas líneas y te irá bien:

Código :

var mouseposX:Number = Math.floor(this._parent.dragscale._x);
var mouseposY:Number =  Math.floor(this._parent.dragscale._y);


Y estas

Código :

var boundleft:Number = this._parent["boundbox" + column]._x;
var boundright:Number = boundleft + this._parent["boundbox" + colnum]._width;
var boundtop:Number =  this._parent["boundbox" + colnum]._y;
var boundbottom:Number = boundtop + this._parent["boundbox" + colnum]._height;

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 04 Ago 2008 11:35 am
listo....anda perfecto....mil gracias

Por buffy299

26 de clabLevel



 

msie

 

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