Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/10/2011, 05:58
Fran1985
 
Fecha de Ingreso: septiembre-2010
Ubicación: Valencia, Spain, Spain
Mensajes: 17
Antigüedad: 13 años, 8 meses
Puntos: 1
Menú giratorio AS2

Hola a todos!!

He estado probando cosas de as2, que hacía tiempo que no tocaba nada de flash. Quería hacer un menú con 4 botones de diferentes colores y que van rotando en elipse. Cada botón es un movieclip que tiene una animación fade in y fade out.

El problema es, que si me pongo en cualquier botón, se anima, pero se detiene, y el resto sigue girando, con lo cual, pierde su posición y se amontonan los botones.

He de decir, que seguí un tutorial para hacer que los botones giraran, y lo hacen si se desplaza el ratón, me gustaría que giraran sin estar dependientes del movimiento del ratón, pero no se me ocurre como hacerlo...


Dejo el código as2:

En la escena, sólo hay un fotograma:

stop();

var botones:Number = 4;
var incr:Number = ( 2 * Math.PI ) / botones;
var amp_x:Number = 270;
var amp_y:Number = 60;
var eje_x:Number = Stage.width / 2;
var eje_y:Number = Stage.height / 2;
var speed:Number=0.05;

for ( i = 0; i < 5; i++){
_root.attachMovie( "boton" + i, "boton" + i, 4 + i);
ref = _root["boton" + i];
ref.angle = incr * i;
ref.onEnterFrame = mover;
}

function mover(){
this._x = Math.cos(this.angle) * amp_x + eje_x;
this._y = Math.sin(this.angle) * amp_y + eje_y;
var s = this._y /(eje_y+amp_y);
this._xscale = this._yscale = s*100;
this.angle += this._parent.speed;
this.swapDepths(Math.round(this._xscale) + 100);
}

El código de cada botón:

En una capa, con 10 fotogramas, el primero es clave:

onEnterFrame = function(){
this._x = (Math.cos(this.angulo) * _root.amp_x) + _root.eje_x;
this._y = (Math.sin(this.angulo) * _root.amp_y) + _root.eje_y;
this._yscale = this._xscale = (this._y - 350) * 0.7 + 100;
this.swapDepths(this._y);
this.angulo += _root.vel;
}

onRollOver=function(){
onEnterFrame=function(){
if(_currentframe!=10){
this.nextFrame();
}else{
stop();
delete this["onEnterFrame"];
}
}
}

onRollOut=function(){
onEnterFrame=function(){
if(_currentframe!=1){
prevFrame();
}else{
stop();
delete this["onEnterFrame"];
}
}
}


En otra capa, 10 fotogramas, el primero y el ultimo claves contienen un stop(); para detener la animación.

Espero que alguien me pueda orientar para poder solucionarlo. Gracias!!

Última edición por Fran1985; 06/10/2011 a las 08:15