Comunidad de diseño web y desarrollo en internet online

como traducir este código de actionscript 1.0 a 2.0 ????

Citar            
MensajeEscrito el 04 Nov 2009 03:49 pm
Hola chicos, viendo tutoriales, me encontré uno de como hacer una cuearda elastica en as para aplicar la idea en mi primera web. el problema es que la web la tengo bastante avanzada y está hecha en actionscript 2.0 para flash player 9.

El efecto de cuerda elastica está realizado en actionscript 1.0 y para flash player 6, el efecto no se ve si lo muestro en el flash player 9.

Seguramente el problema se soluciona pasando el código de as 1.0 a as 2.0 pero no he encontrado un "diccionario" que me ayude a traducirlo.


los codigos a pasar de as1 a as 2 serían:

Código ActionScript :

onClipEvent(enterFrame) {
   _x = _root.cross._x;
   _y = _root.cross._y;
   _xscale = (_root.ball._x - _root.cross._x);
   _yscale = (_root.ball._y - _root.cross._y);
   updateAfterEvent();
}




Código ActionScript :

onClipEvent (load) {
   defaultX = _x;
   defaultY = _y;
   rotaini = 0;
   newXpos = defaultX;
   newYpos = defaultY;
   newrotation0 = 0;
   ratio = 0.05;
}
onClipEvent (enterFrame) {
   if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
      this.onRollOver = function() {
         num = Math.round(Math.random()*40)-40;
         newrotation0 = (this._rotation+num-this._rotation);
         newrotation = newrotation0;
      };
      xDifference = _root._xmouse-defaultX;
      yDifference = _root._ymouse-defaultY;
      newXpos = (_root._xmouse-xDifference/maxDistance);
      newYpos = (_root._ymouse-yDifference/maxDistance);
      _x += newX;
      _y += newY;
   } else {
      newXpos = defaultX;
      newYpos = defaultY;
      newrotation = rotaini;
   }
   newX = (newX*friction)+((newXpos-_x)*ratio);
   newY = (newY*friction)+((newYpos-_y)*ratio);
   _x += newX;
   _y += newY;
   _rotation += (newrotation-_rotation)*0.10;
}




¿Alguien me puede ayudar?

[BOFH]Cuando publiques código ActionScript colócalo entre las etiquetas [*as] y [*/as] (sin los asteriscos) para que sea más legible. The Fricky![/BOFH]

Por pindexo

11 de clabLevel



 

firefox
Citar            
MensajeEscrito el 08 Nov 2009 03:04 am
Segun yo, entre AS 1.0 Y AS 2.0 no hay ningun problema de conversión... el problema esta si lo quieres en 3.0 ahi si cambia la cosa.... segun yo no tendrias por que tener problemas que error te marca? tal vez no lo estas implementando bien

Por MiactionScript

77 de clabLevel



 

chrome
Citar            
MensajeEscrito el 09 Nov 2009 10:24 pm
Como dicen no exista grandes problema de sintaxis, pero SI existe uuna manera correcta de programar en AS2.

Siempre pon tu codigo en el timeline (liea detiepo, fotograma principal)

Código ActionScript :

miClip.onenterFrame = function ()
{
   this._x = _root.cross._x;
   this._y = _root.cross._y;
   this._xscale = (_root.ball._x - _root.cross._x);
   this._yscale = (_root.ball._y - _root.cross._y);
   updateAfterEvent();
}

Código ActionScript :

miClip.onenterFrame = function ()
{
   defaultX = this._x;
   defaultY = this._y;
   rotaini = 0;
   newXpos = defaultX;
   newYpos = defaultY;
   newrotation0 = 0;
   ratio = 0.05;
}
miClip.onenterFrame = function ()
{
   if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
      this.onRollOver = function() {
         num = Math.round(Math.random( *40) -40;
         newrotation0 = (this._rotation + num-this._rotation);
         newrotation = newrotation0;
      };
      xDifference = _root._xmouse - defaultX;
      yDifference = _root._ymouse - defaultY;
      newXpos = (_root._xmouse - xDifference / maxDistance);
      newYpos = (_root._ymouse - yDifference / maxDistance);
      this._x += newX;
      this._y += newY;
   } else {
      newXpos = defaultX;
      newYpos = defaultY;
      newrotation = rotaini;
   }
   newX = (newX * friction) + ((newXpos - _x) *ratio);
   newY = (newY * friction) + ((newYpos - _y) *ratio);
   this._x += newX;
   this._y += newY;
   this._rotation += (newrotation - _rotation) *0.10;
}

miClip es el nombre de instancia del objeto al q se le aplican las acciones

Por penHolder

Claber

4661 de clabLevel

39 tutoriales
2 articulos

Genero:Masculino   Premio_Secretos

| mdz |

firefox
Citar            
MensajeEscrito el 10 Nov 2009 07:07 pm
me sigue sin funcionar, al publicarlo para flasplayer 9 no funciona, solo rota el objeto un poco si m epongo sobre el , pero pierde el efecto de elasticidad, subo un linck con el archivo por si alguien puede ayudame.

puf¡¡¡ estos codigos que lio¡¡¡

http://rapidshare.com/files/305109430/gomaelastica1.fla.html

Por pindexo

11 de clabLevel



 

firefox
Citar            
MensajeEscrito el 25 Nov 2009 06:10 pm
algún alma caritativa que me ayude a traducir as1 a as2??

Por pindexo

11 de clabLevel



 

firefox
Citar            
MensajeEscrito el 25 Nov 2009 08:29 pm
Así quedaría la "traducción" del código:

Código ActionScript :

defaultX = miClip._x;
defaultY = miClip._y;
rotaini = 0;
newXpos = defaultX;
newYpos = defaultY;
newrotation0 = 0;
ratio = 0.05;

function moverMC():Void {

   if (miClip.hitTest(_root._xmouse, _root._ymouse, true)) {

      num = Math.round(Math.round(Math.random(1)*40)-40);
      newrotation0 = (miClip._rotation+num-miClip._rotation);
      newrotation = newrotation0;

      xDifference = _root._xmouse-defaultX;
      yDifference = _root._ymouse-defaultY;
      newXpos = (_root._xmouse-xDifference/maxDistance);
      newYpos = (_root._ymouse-yDifference/maxDistance);
      miClip._x += newX;
      miClip._y += newY;

   } else {

      newXpos = defaultX;
      newYpos = defaultY;
      newrotation = rotaini;

   }

   newX = (newX*friction)+((newXpos-_x)*ratio);
   newY = (newY*friction)+((newYpos-_y)*ratio);
   miClip._x += newX;
   miClip._y += newY;
   miClip._rotation += (newrotation-miClip._rotation)*0.10;

   miClip2._x = _root.cross._x;
   miClip2._y = _root.cross._y;
   miClip2._xscale = (_root.ball._x-_root.cross._x);
   miClip2._yscale = (_root.ball._y-_root.cross._y);

}

id = setInterval(moverMC, 0);


La verdad no me baje el .fla, pero eso al menos es a nivel directo la traslación.

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 30 Nov 2009 06:08 pm
graciñas Hernán, intentare usar este código a ver que pasa :)

Por pindexo

11 de clabLevel



 

firefox

 

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