I’m making a site that has a photogallery that consists of thumbnails and rolling over them will bring up the pic, blah blah, here’s what I’m trying to do:
I don’t know how many pictures I’ll have, so when I load the corresponding thumbnails I want to read in the number of thumbnails I need from a .txt file, that way I can just change the value in the text file instead of opening flash and chaning it there when I want to update the amount of pictures I have(I also want to do this so others can update as well). I searched the board and nothing I found helped me anymore than I already had gotten; I’m new, so I must be missing something simply stupid, I’ve attaced the .fla.
When I debug the movie, I see that value for “numThumbs” has taken my intended value of 10, but when I trace it inside of flash I only see “undefined” in the output box, am I not accounting for something? I’ve been at it for a little over an hour and I figured that I shouldn’t spend any more time on something this painstakingly easy, please help!!
using “var”, you’ll be able to use numThumbs only in this onClipEvent, it’s a local variable!!
2.onClip event load happens as soon as the clip appears on stage; as your textfile won’t have loaded in by then, it’s normal the trace returns undefined, numThumbs hasn’t been given a value yet!
3.what’s in your textfile?
4.what use is it retrieving the number of the pics and not their path to load them?
if you can use php, this lil’ script here will send you back the names and total number of your pictures…
if ($dir = opendir("./")) {
while (($file = readdir($dir)) !== false) {
$cont++;
$string.="file$cont=$file&";
}
closedir($dir);
}
$string.="status=OK";
$string.="numThumbs=$cont";
print($string);
I know it’s defined locally in the .fla I provided but it was my last attempt at trying to make it work; I also declared it globally and in a couple of other places before ending in with that.
I also already have a working .fla which loads in my pics, I just need this way to read an input file to work and I’m also not familiar with PHP, so it’d pretty much fck it up.
I figured reading in a value from a txt file would be pretty simple, I guess not!
In a frame I have a Movie Clip symbol created named “aTest”
In the action panel for the frame I have:
loadVariables("data.txt", "aTest");
in the action panel for “aTest” I have:
onClipEvent(load){
trace(numThumbs);
}
trace comes back undefined. I think I’m just declaring the trace at the wrong time because if I add an onClipEvent(enter) and put the trace inside of that, the trace continusouly outputs 10, after a single undefined is outputed first.
Oh “data.txt” is:
numThumbs=10
The good thing is though inside of the debugger I see numThumbs defined and with the right value.
runs when a loadVariables operation finishes loading the variables
onClipEvent(load){}
is for when the clip is iniated and first displayed on the screen. It has nothing to do with loading variables, just loading itself.