Consiste en 2 xml uno carga imagenes que de desplazaran verticalmente y el otro las imagenes que se desplazaran horizontalmente. hasta ahi funciona perfecto aqui el codigo :
Código :
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
//Inicia carga XML
var obj_xml:XML = new XML();
var objv_xml:XML = new XML();
obj_xml.ignoreWhite = true;
objv_xml.ignoreWhite = true;
//CARGO XML HORIZONTALES
obj_xml.onLoad = function(exito) {
trace("Comienza carga XML horizontales");
if (exito) {
control = obj_xml.firstChild.childNodes.length;
img = new Array(control);
tiempo = new Array(control);
iden = new Array(control);
totalh= new Array(control);
//Lleno los Arrays con los datos del XML
for (i=0; i<control; i++) {
img[i] = obj_xml.firstChild.childNodes[i].attributes.imagenh;
tiempo[i] = obj_xml.firstChild.childNodes[i].attributes.delay;
iden[i] = obj_xml.firstChild.childNodes[i].attributes.id;
totalh[i]=obj_xml.firstChild.childNodes[i].attributes.totalh;
}
//Comienzo a crear los clips dinamicos
for (i=0; i<control; i++) {
ref = attachMovie("menuItem", "Item"+i, 1+i);
//Defino la posicion inicial de los clips
posy = randRange(1, 500);
ref._y = posy;
posx = randRange(1, 400);
ref._x = 170*i;
trace(posy);
//Por ultimo cargo las imagenes dentro de los clips nuevos
ref.loadMovie(img[i]);
trace(ref);
trace(img[i]);
}
}
};
//CARGO XML VERTICALES
objv_xml.onLoad = function(exito) {
trace("Comienza carga XML verticales");
if (exito) {
control = objv_xml.firstChild.childNodes.length;
totalv= new Array(control);
imgv = new Array(control);
tiempov = new Array(control);
idenv = new Array(control);
//Lleno los Arrays con los datos del XML
for (i=0; i<control; i++) {
imgv[i] = objv_xml.firstChild.childNodes[i].attributes.imagenv;
tiempov[i] = objv_xml.firstChild.childNodes[i].attributes.delay;
idenv[i] = objv_xml.firstChild.childNodes[i].attributes.id;
totalv[i] = objv_xml.firstChild.childNodes[i].attributes.totalv;
}
//Comienzo a crear los clips dinamicos
for (i=0; i<control; i++) {
ref = attachMovie("menuItemV", "ItemV"+i, 10+i);
//Defino la posicion inicial de los clips
posy = randRange(1, 500);
ref._y = 110*i;
posx = randRange(1, 700);
ref._x = posx;
trace(posy);
//Por ultimo cargo las imagenes dentro de los clips nuevos
ref.loadMovie(imgv[i]);
trace(ref);
trace(imgv[i]);
}
}
};
//MOVIMIENTOS
onEnterFrame = function() {;
//Horizontales
cantidadh = totalh[0];
velocidadh=3;
for(i=0; i<cantidadh; i++) {;
var ref:MovieClip = eval("Item"+i);
ref._x += velocidadh
if(ref._x>900) {
ref._x = -300
}
};
//Fin H
//Verticales
cantidadv = totalv[0];
for(i=0; i<cantidadv; i++) {;
var refv:MovieClip = eval("ItemV"+i);
refv._y +=5;
if(refv._y>600) {;
refv._y=-100;
};
}
//Fin V
}
obj_xml.load("configh.xml");
objv_xml.load("configv.xml");
De esta manera tengo una serie de imagenes que van de arriba hacia abajo constantemente y de izquierda a derecha constantemente...
ahora mi problema es que necesito que por ejemplo cuando lleguen al costado derecho reboten y vallan hacia el izquierdo y asi consecutivamente.
he intentado varias formas pero lo que me pasas es que algunas imagenes rebotan y otras siguen de largo..
como puedo hacer ??
De todos modos espero que el codigo les sirva de algo esta bueno para armar menus
saludos!
