Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/03/2008, 06:08
SuRpRiSe18
 
Fecha de Ingreso: noviembre-2003
Ubicación: España->Madrid
Mensajes: 368
Antigüedad: 20 años, 4 meses
Puntos: 0
Referencia a un objeto en AS

Hola, estoy terminando una animación de una galería de imágenes que cargan las carpetas desde una carpeta externa.

El problema que tengo es que tengo varios MC donde se cargan las imagenes y por alguna razón cuando intento referenciarlos de forma dinámica, el AS no hace nada, mientras que si lo hago de forma manual funciona perfectamente. El código es el siguiente:

Código:
this.pathToPics = "fotos/";
this.pArray = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", "7.jpg", "8.jpg", "9.jpg", "10.jpg", "11.jpg", "12.jpg", "13.jpg"];
this.dArray = ["marco1", "marco2", "marco3", "marco4", "marco5", "marco6", "marco7", "marco8"];
this.fadeSpeed = 1;
this.load = true;

if(this.load == true) {
	numMC = this.dArray.length;
	
	for (i=0; i<numMC; ++i) {
		ranPhoto = Math.floor(Math.random()*13);
		loadMovie(this.pathToPics+this.pArray[ranPhoto], _root.dArray[i]);
	}
	
	this.load = false;
}

MovieClip.prototype.changePhoto = function(p,d) {
	this.pIndex = p;
	this.dIndex = d;
	this.onEnterFrame = fadeOut;
};

MovieClip.prototype.fadeOut = function() {
	if (this.dArray[this.dIndex]._alpha > this.fadeSpeed) {
		this.dArray[this.dIndex]._alpha -= this.fadeSpeed;
	} else {
		this.loadPhoto();
	}
};

MovieClip.prototype.loadPhoto = function() {
	var p = _root+this.dArray[this.dIndex];
	p._alpha = 0;
	p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
	this.onEnterFrame = loadMeter;
};

MovieClip.prototype.loadMeter = function() {
	var i, l, t;
	l = this.dArray[this.dIndex].getBytesLoaded();
	t = this.dArray[this.dIndex].getBytesTotal();
	if (t>0 && t == l) {
		this.onEnterFrame = fadeIn;
	}
};

MovieClip.prototype.fadeIn = function() {
	if (this.dArray[this.dIndex]._alpha < 100 - this.fadeSpeed) {
		this.dArray[this.dIndex]._alpha += this.fadeSpeed;
	} else {
		this.dArray[this.dIndex]._alpha = 100;
		this.onEnterFrame = null;
	}
};

this.onKeyDown = function() {
	if (Key.getCode() == Key.RIGHT) {
		ranPhoto = Math.floor(Math.random() * (13 -  0)) + 0;
		numMC = this.dArray.length;
		ranMC = Math.floor(Math.random() * (numMC -  1));
		this.changePhoto(ranPhoto, ranMC);
	}
};

Key.addListener(this);
Pues bien, si sustituyo "dArray[this.dIndex]" por el nombre de alguno de mis MC, como por ejemplo marco1, todo funciona, pero sino no...

Alguna idea? Gracias de antemano!