Tengo esta situación. He creado varias instancias de un movie clip las cuales se animan en direcciones random. Para la animación estoy utilizando los métodos de la clase Tween de ASc3. Para dar continuidad a la animación he agregado un Listener a mi objeto Tween que escucha por el evento MOTION_FINISH. entonces utilizo el método continueTo(). Es aquí donde la mágina no sucede. Pasa que únicamente responde al evento, la última instancia.
¿Hay alguna manera de trabajar alrededor de esta situación? ¿Realmente puedo hacerlo así, o debo considerar una solución diferente?
Mi código es el siguiente:
Código ActionScript :
//IMPORTACIONES
import fl.transitions.easing.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
//FUNCION QUE GENERA NUMEROS RANDOM
function Random(_min:Number, _max:Number):Number
{
var num:Number = Math.floor(Math.random() * (_max - _min + 1)) + _min;
return num;
}
//CREO COPIAS DEL CLIP
for (var i:Number = 0; i <= 10; i ++)
{
var cora:c3 = new c3();
holder.addChild(cora);
cora.name = "corazonAzul" + i;
//COLOCO LAS COPIAS DEL CLIP EN UNA POSICIÓN RANDOM INICIAL
holder.getChildByName("corazonAzul" + i).x = Random(-380, 380);
holder.getChildByName("corazonAzul" + i).y = Random(-220, 220);
//ANIMO LAS INSTANCIAS DEL CLIP CON LA CLASE TWEEN
//anima posición X
var anipx:Tween = new Tween(holder.getChildByName("corazonAzul" + i),"x",None.easeNone,holder.getChildByName("corazonAzul" + i).x,Random(-380,380),100,false);
//anima posición Y
var anipy:Tween = new Tween(holder.getChildByName("corazonAzul" + i),"y",None.easeNone,holder.getChildByName("corazonAzul" + i).y,Random(-220, 220),100,false);
//anima rotación
var aniR:Tween = new Tween(holder.getChildByName("corazonAzul" + i),"rotation",None.easeNone,holder.getChildByName("corazonAzul" + i).rotation,Random(-360,360),100,false);
}
//FUNCIONES QUE MANEJAN LOS EVENTOS DEL OBJETO TWEEN
function anipxFUN(event:TweenEvent):void
{
anipx.continueTo(Random(-380,380),100);
}
function anipyFUN(event:TweenEvent):void
{
anipy.continueTo(Random(-220,220),100);
}
function anirFUN(event:TweenEvent):void
{
aniR.continueTo(Random(-360,360),100);
}
//asigno el listener a los objetos tween
anipx.addEventListener(TweenEvent.MOTION_FINISH, anipxFUN);
anipy.addEventListener(TweenEvent.MOTION_FINISH, anipyFUN);
aniR.addEventListener(TweenEvent.MOTION_FINISH, anirFUN);
//FIN DEL CODIGO
Gracias por cualquier ayuda que me puedan dar.
