Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/07/2011, 17:23
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 11 meses
Puntos: 310
Respuesta: Cambiar fondo

Usa algo como esto:
Código Javascript:
Ver original
  1. Array.prototype.porOrden = function(){
  2.  this.esNuevo = this.esNuevo == null;
  3.  this.copia = this.esNuevo || !this.copia.length ? this.concat() : this.copia;
  4.  return this.copia.shift();
  5. };
  6. var array = [1, 'abc', true, {}, []], i = 0;
  7.  
  8. while(i++ < 5){ console.log(array.porOrden()); }
Saludos (:
PD: Lo que sucede es que al usar Math.ceil, la única manera de que salga fondo3.png es que Math.random() devuelva 0, algo que es bastante improbable. Usa mejor Math.round.
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red