Help Newbie - loadVariables is working only in my pc :(

Hi

I’m newbie in AS Flash (and new in this foro) and I have 3 swf.
Principal is the first one that loads pliego and this one load textos.

I have 3 files txt’s and 3 files jpg’s by now (_global.tope=2) and
All is OK while I’m testing on my pc.

When I’m testing on my site, the Dynamic Text doesn’t load txt files!
The size of biggest file txt are 5 KB

What are going wrong?

Thanks for help me

Alegria

p.d.: attached is script of the 3 fla’s

Let me write that down here, so we can read it:


// Principal INDEX.swf
stop();
// LAS VARIABLES GLOBALES ESAS
_global.num = 0;
_global.tope = 2;
_global.str = "plitn";
// LA COSA DE LOS CARACTERES
System.UseCodepage = true;
ponerboton(0);
// CREO UN MC VACIO PARA USARLO EN POSTERIORES CARGAS
this.createEmptyMovieClip("container", 10);
// PARA EL BOTON PLIEGO
bot_pliego.onRelease = function() {
	//_root.uno._alpha = 30;
	container._x = 25;
	container._y = 25;
	//container._x = 40;
	//container._y = 155;
	ponerboton(1);
	container.loadMovie("pliego.swf");
};
// PARA EL BOTON INICIAR
iniciar.onRelease = function() {
	container.unloadMovie();
	//_root.uno._alpha = 100;
	ponerboton(0);
	this.loadMovie("index.swf");
};
// FUNCION PARA INHABILITAR BOTONES NO USADOS
function ponerboton(estadoboton) {
	_root.iniciar._visible = estadoboton;
	_root.bot_pliego._visible = !estadoboton;
}

-----------------------------------------
// Secundario PLIEGO.swf
// Este swf será cargado dinámicamente según sea el destino elegido
// La variable str será asignada fuera de este swf, por ahora lo dejo aquí
// CREO UN MC VACIO PARA USARLO EN POSTERIORES CARGAS
stop();
this.createEmptyMovieClip("contiene", 20);
_global.num = 0;

cargarr();
boton_dcha.onRelease = function() {
	if (_global.num<tope) {
		_global.num += 1;
		cargarr();
	} else {
		_global.num = tope;
	}
};
boton_izda.onRelease = function() {
	if (_global.num>0) {
		_global.num -= 1;
		cargarr();
	} else {
		_global.num = 0;
	}
};
function cargarr() {
	this.createEmptyMovieClip("mv1", 0);
	mv1.createEmptyMovieClip("mv1b", 1);
	mv1.mv1b.loadMovie(_global.str+_global.num+".jpg");
	mv1.onEnterFrame = function() {
		if (mv1._width>0) {
			mv1._width = 140;
			mv1._height = 95;
			mv1._x = 5;
			mv1._y = 5;
			delete mv1.onEnterFrame;
		}
	};
	// CARGAMOS EL TITULO
	this.loadVariables(_global.str+_global.num+".txt");
	if (titulo<>undefined) {
		presentitulo.text = titulo;
		delete this.onEnterFrame;
	}
	// CARGAMOS TEXTOS
	contiene._x = 30;
	contiene._y = 145;
	contiene.loadMovie("textos.swf");
}

---------------------------------------------------------------
// Secundario TEXTOS.swf

stop();
this.createEmptyMovieClip("cargador", 0);
this.loadVariables(_global.str+_global.num+".txt");
barra.setStyleProperty("arrow", 0x039603);
barra.setStyleProperty("highlight3D", 0xF20104);
barra.setStyleProperty("highlight", 0xF20104);
barra.setStyleProperty("face", 0xF20104);
cargador.onEnterFrame = function() {
	if (variable<>undefined) {
		cajatexto.text = variable;
		delete this.onEnterFrame;
	}
};




I haven’t looked at the rest of the code, only the loadVariables part. Are you sure the path to your textfile is correct ? Because it might work offline because the path offline is correct, but online it has to be correct too. Also, I suggest you use the loadVars object instead of loadVariables:


lv = new loadVars();
lv.onLoad = function(){
for(all in this){
trace(this[all])
}
// Use this.message for example to target a variable from the textfile
}
lv.load("http://www.server.com/file.txt");

*Welcome to the forum by the way :wink:

Grateful :slight_smile:

After fight with the code a while, I have this an still only works
on my pc…

Also I’m looking at some method to get if load has finished, and
then continue

// set variable to get load, the path is relative so I think is OK ??
var arctexto = _global.str+_global.num+".txt";
loadText = new loadVars();
loadText.load(arctexto);
trace(arctexto)
loadText.onLoad = function(success) {
if (success) {
// trace(success);
presentitulo.html = true;
presentitulo.htmlText = this.titulo;
}
};

could you give a trick about “get if loaded really”?
thanks a lot :slight_smile:

To see if it’s loaded, you can check if loadText.getBytesTotal() is not zero. Try changing your relative path to an absolute path, so not folder/file.txt, but http://www.server.com/folder/file.txt

Don’t ask me why, but now is working OK :open_mouth:
Only I have done now are:

1- Delete all files in my web site
2- Upload again
3- Before Run, close all FLA ¿?

again, thanks

— ActionScript working finally :))
function LeeTexto() {
// ESTA VARIABLE INDICA EL ARCHIVO A SEGUIR Y ES RUTA RELATIVA
arctexto = _global.str+_global.num+".txt";
// CREAMOS UN OBJETO LOADVARS
loadText = new loadVars();
// MIRAMOS SI HAY CARGA CORRECTA, SI ES ASI; ASIGNAMOS LAS VARIABLES
// REQUERIDAS, INCLUSO LA GLOBAL QUE SE USA EN TEXTOS.SWF
loadText.onLoad = function(success) {
if (success) {
// trace(success);
presentitulo.html = true;
presentitulo.htmlText = this.titulo;
_global.relato = this.variable;
}
};
// CARGAMOS EL ARCHIVO DE TEXTO
loadText.load(arctexto);
}

Probably the absolute path :wink: