Comunidad de diseño web y desarrollo en internet online

Animación con random y varios mc's

Citar            
MensajeEscrito el 16 Jul 2009 09:28 pm
Hola a todos, a ver si me pueden ayudar con esto...

Lo que intento hacer es crear un entramado con mc's (son circulos - 9 filas y 18 columnas), eso lo hice con este código

Código ActionScript :

var espacioX:Number = 21.5;
var espacioY:Number = 21.5;
var columnas:Number = 18;
var filas:Number = 9;
for (a=0; a<filas; a++) {
   for (b=0; b<columnas; b++) {
      bola = this.attachMovie("bolita", "b"+a+b, this.getNextHighestDepth());
      bola._x = 8.9+(b*espacioX);
      bola._y = 8.9+(a*espacioY);
   }
}

ahora quiero hacer una animación para que las bolitas cambien de color con transición y luego regresen a su color original, la bolita que cambia de color la llamo con un random y asi generar un ciclo que este cambiando de color las bolitas... eso lo hice con este otro codigo

Código ActionScript :

#include "lmc_tween.as"
function aparece() {
   ye = int(Math.random()*filas);
   ex = int(Math.random()*columnas);
   rosa = this["b"+ye+ex];
   colors();
}
function colors() {
   rosa.colorTo(0xEA3FA9, 1.5, "easeOutSine", 0, onEnd);
}
function onEnd() {
   rosa.colorTo(0x26AECE, 1.5, "easeInSine", 0, aparece);
}
aparece();

Hasta aquí todo bien...., ahora quiero que en vez de 1 color sean 5 y que estos desaparezcan y aparezcan en diferentes tiempos, y obvio que siempre se vean 5 bolitas con diferente color (no mas, no menos).
Para esto pensé que en algún momento la bolita "rosa" podría tomar los mismos valores que la "azul", entonces tengo que validar primero si no se esta usando esa bolita y así evitar que me quite la animación de alguna otra...

Hasta ahora tengo esto

Código ActionScript :

#include "lmc_tween.as"
//
var espacioX:Number = 21.5;
var espacioY:Number = 21.5;
var columnas:Number = 18;
var filas:Number = 9;
var colores:Number = 5;
var ci:Number = 0;
var ye:Array = new Array();
var ex:Array = new Array();
for (a=0; a<filas; a++) {
   for (b=0; b<columnas; b++) {
      bola = this.attachMovie("bolita", "b"+a+b, this.getNextHighestDepth());
      bola._x = 8.9+(b*espacioX);
      bola._y = 8.9+(a*espacioY);
   }
}
intervalo = setInterval(aparece, 100);
//
function valida(nums:Array, num:Number) {
   var salida:Number = 0;
   for (s=0; s<colores; s++) {
      if (nums[s] == num) {
         salida = 1;
      }
   }
   return salida;
}
function buscaObj() {
   ye[ci] = int(Math.random()*filas);
   exs = int(Math.random()*columnas);
   rex = valida(ex, exs);
   while (rex != 0) {
      exs = int(Math.random()*columnas);
      rex = valida(ex, exs);
   }
   ex[ci] = exs;
   rosa = this["b"+ye[0]+ex[0]];
   verde = this["b"+ye[1]+ex[1]];
   azul = this["b"+ye[2]+ex[2]];
   amarillo = this["b"+ye[3]+ex[3]];
   naranja = this["b"+ye[4]+ex[4]];
}
function aparece() {
   buscaObj();
   colors();
   ci++;
   if (ci == colores) {
      clearInterval(intervalo);
      ci = 0;
   }
}
function colors() {
   rosa.colorTo(0xEA3FA9, 1.5, "easeOutSine", 0, onEnd);
   verde.colorTo(0x8CC63F, 1.5, "easeOutSine", 0, onEnd);
   azul.colorTo(0x0CBBEA, 1.5, "easeOutSine", 0, onEnd);
   amarillo.colorTo(0xFDBB30, 1.5, "easeOutSine", 0, onEnd);
   naranja.colorTo(0xF47B20, 1.5, "easeOutSine", 0, onEnd);
}
function onEnd() {
   rosa.colorTo(0x26AECE, 1.5, "easeInSine");
   verde.colorTo(0x26AECE, 1.5, "easeInSine");
   azul.colorTo(0x26AECE, 1.5, "easeInSine");
   amarillo.colorTo(0x26AECE, 1.5, "easeInSine");
   naranja.colorTo(0x26AECE, 1.5, "easeInSine", 0, denuex);
}
function denuex() {
   intervalo = setInterval(aparece, 100);
}

Si hace la animación pero me pone mas bolitas de las 5 que necesito :cry: y todavía falta que se animen a diferente tiempo...

bueno espero que a alguien se le ocurra algo que pueda ayudarme y gracias a quien se tome la molestia :)

a si AYUDAAA!!!!

Por nasho

Claber

908 de clabLevel

1 tutorial

Genero:Masculino  

Web Developer

firefox
Citar            
MensajeEscrito el 17 Jul 2009 12:11 am
Ya estuvo ^^ aunque lo quería hacer con menos lineas...

Código ActionScript :

#include "lmc_tween.as"
//
var espacioX:Number = 21.5;
var espacioY:Number = 21.5;
var columnas:Number = 18;
var filas:Number = 9;
var colores:Number = 5;
var ci:Number = 0;
var ye:Array = new Array();
var ex:Array = new Array();
for (a=0; a<filas; a++) {
   for (b=0; b<columnas; b++) {
      bola = this.attachMovie("bolita", "b"+a+b, this.getNextHighestDepth());
      bola._x = 8.9+(b*espacioX);
      bola._y = 8.9+(a*espacioY);
   }
}
aparece();
//
function valida(nums:Array, num:Number) {
   var salida:Number = 0;
   for (s=0; s<colores; s++) {
      if (nums[s] == num) {
         salida = 1;
      }
   }
   return salida;
}
function buscaObj(ji) {
   exs = int(Math.random()*columnas);
   rex = valida(ex, exs);
   while (rex != 0) {
      exs = int(Math.random()*columnas);
      rex = valida(ex, exs);
   }
   ex[ji] = exs;
   //
   yes = int(Math.random()*filas);
   rey = valida(ye, yes);
   while (rey != 0) {
      yes = int(Math.random()*filas);
      rey = valida(ye, yes);
   }
   ye[ji] = yes;
   //
   rosa = this["b"+ye[0]+ex[0]];
   verde = this["b"+ye[1]+ex[1]];
   azul = this["b"+ye[2]+ex[2]];
   amarillo = this["b"+ye[3]+ex[3]];
   naranja = this["b"+ye[4]+ex[4]];
}
function aparece() {
   for (i=0; i<colores; i++) {
      buscaObj(i);
   }
   intervalo = setInterval(colors, 500);
}
function colors() {
   eval("c"+ci)();
   ci++;
   if (ci == colores) {
      clearInterval(intervalo);
   }
}
function c0() {
   rosa.colorTo(0xEA3FA9, 1.5, "easeOutSine", 0, onEndr);
}
function c1() {
   verde.colorTo(0x8CC63F, 1.5, "easeOutSine", 0, onEndv);
}
function c2() {
   azul.colorTo(0x0CBBEA, 1.5, "easeOutSine", 0, onEndz);
}
function c3() {
   amarillo.colorTo(0xFDBB30, 1.5, "easeOutSine", 0, onEnda);
}
function c4() {
   naranja.colorTo(0xF47B20, 1.5, "easeOutSine", 0, onEndn);
}
function onEndr() {
   rosa.colorTo(0x03A7CF, 1.5, "easeInSine", 0, c0);
   buscaObj(0);
}
function onEndv() {
   verde.colorTo(0x03A7CF, 1.5, "easeInSine", 0, c1);
   buscaObj(1);
}
function onEndz() {
   azul.colorTo(0x03A7CF, 1.5, "easeInSine", 0, c2);
   buscaObj(2);
}
function onEnda() {
   amarillo.colorTo(0x03A7CF, 1.5, "easeInSine", 0, c3);
   buscaObj(3);
}
function onEndn() {
   naranja.colorTo(0x03A7CF, 1.5, "easeInSine", 0, c4);
   buscaObj(4);
}

Por nasho

Claber

908 de clabLevel

1 tutorial

Genero:Masculino  

Web Developer

firefox

 

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