Comunidad de diseño web y desarrollo en internet online

Problema con menú AS 1.0 a AS 2.0 :S

Citar            
MensajeEscrito el 02 Dic 2009 07:53 pm
Hola gente!

Estaba el otro dia fisgando código de cristalab i dí con un menú precioso rotatorio con efectos de 3D, lo estube modificando i jugando con él... Pero tengo un problemón, solo me compila en modo Flash 6 i AS 1.0... i mi juego funciona sobre Flash 8 con AS 2.0 y no se como traducirlo :S

Alguien podria ayudar-me??

PD: el archivo entero está aquí: http://www.cristalab.com/ejemplos/menu-con-elementos-tridimensional-giratorios-c30l/

Código ActionScript :

//proto q movera las letras

MovieClip.prototype.carusel = function(mover, posicionFinal) 
{
   mueveAngulo(posicionFinal);
   
   if (mover) 
   {
         this.onEnterFrame = function() {
         this._x = centrox+Math.cos((Math.PI/180)*(angulo+this.angulo))*radio;
         this._y = centroy+Math.sin((Math.PI/180)*(angulo+this.angulo))*radio/-20;
         this.z = Math.sin((Math.PI/180)*(angulo+this.angulo))*radio;
         this._alpha = this._yscale=this._xscale=(100*distanciafocal)/(distanciafocal+this.z);
         this.swapDepths(-1*this.z);
         }
   } else {
      delete this.onEnterFrame;
   }
};

function mueveAngulo(posicionFinal) {
   this.onEnterFrame = function() {
      if ((Math.round(angulo)) == Math.round(posicionFinal)) {
         mueveLetras(false);
         delete this.onEnterFrame;
      } else {
         //contador de frames
         if (counter++%30 == 1) {
            // updates every 30 frames
            thisTime = getTimer();
            rate = Math.round(10000/(thisTime-lastTime))/10;
            if (rate%1 == 0) {
               rate += ".0";
            }
         } else if (counter%30 == 1) {
            lastTime = getTimer();
         }
         angulo += ((posicionFinal-angulo)/30);
      }
   };
}

//para ir sumando la profundidad

function maxprofundidad() {
   return ++profundidad;
}

//inicio variables

centrox = 700/2;
centroy = 200;
radio = 220;
distanciafocal = 350;

//creando los titulos

titulos = "Jugar      Instrucciones      Opciones      ";

//creando los clips q contendran las letras

function creaLetras() {
   letras = new Array();
   for (i=0; i<=titulos.length; i++) {
      letras[i] = titulos.substr(i, 1);
      var letra = this.attachMovie("letrita", "letrita"+i, maxprofundidad());
      letra.angulo.i = i;
      letra.angulo = (360/titulos.length)*i;
      letra.contenido.text = letras[i];
      letra.carusel(true, 249);
      //trace(letra);
   }
}

creaLetras();

function mueveLetras(mover, posicionFinal) {

   for (i=0; i<=titulos.length; i++) {
      this["letrita"+i].carusel(mover, posicionFinal);
      
   }
}

b1.onPress = function() {
   mueveLetras(true, 252);
};
b2.onPress = function() {
   mueveLetras(true, 130);
};
b3.onPress = function() {
   mueveLetras(true, -5);
};

stop();


Muchísimas grácias por adelantado!!

Por MuertoKo

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 02 Dic 2009 11:01 pm
Wow, me sorprende que funcionase alguna vez, tiene muchas cosas "opinables". Corregí muchas de esas cosas, actualice un poco el código, aunque no puedo transferirlo por completo, el Prototype sigue siendo valido pero no es ya usado, antes era "c00l".

Código ActionScript :

//proto q movera las letras 
MovieClip.prototype.carusel = function(mover, posicionFinal):Void  {

   if (mover) {

      this.onEnterFrame = function() {

         if ((Math.round(angulo)) == Math.round(posicionFinal)) {
            mueveLetras(false,0);
            delete this.onEnterFrame;
         } else {
            //contador de frames 
            if (counter++%30 == 1) {
               // updates every 30 frames 
               thisTime = getTimer();
               rate = Math.round(10000/(thisTime-lastTime))/10;
               if (rate%1 == 0) {
                  rate += ".0";
               }
            } else if (counter%30 == 1) {
               lastTime = getTimer();
            }
            angulo += ((posicionFinal-angulo)/30);
         }

         this._x = centrox+Math.cos((Math.PI/180)*(angulo+this.angulo))*radio;
         this._y = centroy+Math.sin((Math.PI/180)*(angulo+this.angulo))*radio/-20;
         this.z = Math.sin((Math.PI/180)*(angulo+this.angulo))*radio;
         this._alpha = this._yscale=this._xscale=(100*distanciafocal)/(distanciafocal+this.z);
         this.swapDepths(this.z*-1);
      };

   } else {

      delete this.onEnterFrame;

   }

};

//para ir sumando la profundidad 
function maxprofundidad():Number {
   return profundidad++;
}

//inicio variables 
centrox = 700/2;
centroy = 200;
radio = 220;
distanciafocal = 350;

//creando los titulos 
titulos = "Jugar      Instrucciones      Opciones      ";

//creando los clips q contendran las letras 
function creaLetras():Void {

   var letras = [];
   for (var i = 0; i<=titulos.length; i++) {
      letras[i] = titulos.substr(i, 1);
      letra = this.attachMovie("letrita", "letrita"+i, maxprofundidad());
      letra.angulo.i = i;
      letra.angulo = (360/titulos.length)*i;
      letra.contenido.text = letras[i];
      letra.carusel(true,249);
   }

}

function mueveLetras(mover, posicionFinal):Void {

   for (i=0; i<=titulos.length; i++) {
      this["letrita"+i].carusel(mover,posicionFinal);
   }

}

creaLetras();

b1.onPress = function() {
   mueveLetras(true,252);
};
b2.onPress = function() {
   mueveLetras(true,130);
};
b3.onPress = function() {
   mueveLetras(true,-5);
};

stop();


Saludos, Hernán . -

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox
Citar            
MensajeEscrito el 03 Dic 2009 09:58 pm
Me lo he estado mirando con calma y no lo entiendo, sigue sin compilar usando Flash 8 con AS 2.0... Que le da por fallar ahora? Me lleva loco... compilando el código original en Flash 8 lo único que pasaba es k no aparecia ningún menú, ahora con tu código no va ni con 6 ni con 8 xDDD Ya no entiendo nada :S:S Socorrroooo! xD

Seguiré mirando a ver si consigo dar cone l problema ya os mantendré informados :)

Grácias!!

Por MuertoKo

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 05 Dic 2009 03:02 am
Pues... ¿Cual es la idea del código en sí mismo? ¿Puedes mostrar el ejemplo SWF al menos el que funcionaba en AS 1?

Saludos, Hernán . -

Por Hernán

BOFH

6148 de clabLevel

19 tutoriales
23 articulos

Genero:Masculino   REC Desarrollador de GAIA

Marketing & IT

firefox
Citar            
MensajeEscrito el 05 Dic 2009 12:32 pm

Por MuertoKo

1 de clabLevel



 

firefox

 

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