sebnewyork
05-14-2005, 04:52 PM
Hi all
I am making a dynamic slide show with flash and a PHP script. The PHP script gets the list of images in a folder, sends the total number of images and their path to flash, and then flash loads the images one after another. I've got this working perfectly.
The problem is I want to do exactly the same thing, but with text files instead of images.
And for some reason, I can't get it to work. I just don't understand well enough the logic behind loading text files.
here's my script to load the images, and it works:
var loadImages:LoadVars = new LoadVars();
loadImages.onLoad = function() {
if (this.totalImages != undefined) {//totalImages is the total number of images sent by the PHP script
imagesToLoad = new Array();
for (var i = 0; i < this.totalImages; i++) {
imagesToLoad[i] = this["img"+i];
}
_root.stage0.createEmptyMovieClip("loader0", 0);
_root.stage0.loader0.createEmptyMovieClip("holder0", 0);
_root.stage0.loader0.holder0.loadMovie(imagesToLoa d[0]);
_root.stage0.loader0.onEnterFrame = function() {
trace(this.holder0._width);
if (this.holder0._width != 0) {
delete this.onEnterFrame;
_root.stage0.gotoAndPlay(2);
}
}
}
}
var imagesToLoad:Array;
loadImages.load(to_php+"?ck="+new Date().getTime()+"&path="+urlpath);
So I tried to adapt that for loading text files, and i can't get it to work:
var loadTexts:LoadVars = new LoadVars();
loadTexts.onLoad = function() {
if (this.totalImages != undefined) {//I am using the same PHP script to list the text files than the one I use to list the image files, so here totalImages in ths total number of text files...
textsToLoad = new Array();
for (var i = 0; i < this.totalImages; i++) {
textsToLoad[i] = this["txt"+i];
}
_root.stage0.txt_MC.text = textsToLoad[0];//'text_MC' is my dynamic text field, inside the MC 'stage0'
_root.stage0.gotoAndPlay(2);
}
}
var textsToLoad:Array;
loadTexts.load(to_php+"?ck="+new Date().getTime()+"&path="+urlpath);
Could you help me adapt the first script to the second so that it loads texts instead of images?
I am making a dynamic slide show with flash and a PHP script. The PHP script gets the list of images in a folder, sends the total number of images and their path to flash, and then flash loads the images one after another. I've got this working perfectly.
The problem is I want to do exactly the same thing, but with text files instead of images.
And for some reason, I can't get it to work. I just don't understand well enough the logic behind loading text files.
here's my script to load the images, and it works:
var loadImages:LoadVars = new LoadVars();
loadImages.onLoad = function() {
if (this.totalImages != undefined) {//totalImages is the total number of images sent by the PHP script
imagesToLoad = new Array();
for (var i = 0; i < this.totalImages; i++) {
imagesToLoad[i] = this["img"+i];
}
_root.stage0.createEmptyMovieClip("loader0", 0);
_root.stage0.loader0.createEmptyMovieClip("holder0", 0);
_root.stage0.loader0.holder0.loadMovie(imagesToLoa d[0]);
_root.stage0.loader0.onEnterFrame = function() {
trace(this.holder0._width);
if (this.holder0._width != 0) {
delete this.onEnterFrame;
_root.stage0.gotoAndPlay(2);
}
}
}
}
var imagesToLoad:Array;
loadImages.load(to_php+"?ck="+new Date().getTime()+"&path="+urlpath);
So I tried to adapt that for loading text files, and i can't get it to work:
var loadTexts:LoadVars = new LoadVars();
loadTexts.onLoad = function() {
if (this.totalImages != undefined) {//I am using the same PHP script to list the text files than the one I use to list the image files, so here totalImages in ths total number of text files...
textsToLoad = new Array();
for (var i = 0; i < this.totalImages; i++) {
textsToLoad[i] = this["txt"+i];
}
_root.stage0.txt_MC.text = textsToLoad[0];//'text_MC' is my dynamic text field, inside the MC 'stage0'
_root.stage0.gotoAndPlay(2);
}
}
var textsToLoad:Array;
loadTexts.load(to_php+"?ck="+new Date().getTime()+"&path="+urlpath);
Could you help me adapt the first script to the second so that it loads texts instead of images?