I have successfully managed to finish the tutorial covering text files, but I cannot get it to work with my own scenario:
I have 1 movie that acts as a photo gallery, loading up pictures based on navigation buttons or user input. I am attempting to add captions to each picture by using a dynamic text box, and having it filled in with values from the text file. I will worry about the navigation aspect of this later, but for right now I cannot seem to get the text to show up on my movie. I have checked the font and that is a different color than the background, and it is on its own layer. Here is how things are set up:
Dynamic Text Box:
Instance name (also tried var) = mycaption
Text file:
“mycaption.txt”
values:
caption=this is a test
Actionscript:
[AS]
//loads in the caption for each picture
loadText = new loadVars();
loadText.load(“mycaption.txt”);
loadText.onLoad = function() {
caption.text = this.mycaption;
}[/AS]
Again, when I test the movie in either flash or the web, I cannot see any text in the text box.
Thanks for any and all help!!
I aint to sure but…
Is the text file in the same directory as your SWF File.
What i mean is that is your "mycaption.txt in the same Folder as your SWF File.
Same goes with Website make sure you upload both of them.
[AS]loadText = new loadVars();
loadText.load(“mycaption.txt”);
loadText.onLoad = function() {
caption.text = this.mycaption;
}
[/AS] Should be:[AS]loadText = new loadVars();
loadText.load(“mycaption.txt”);
loadText.onLoad = function() {
captions.text = this.caption;
}
[/AS][edit]assuming your textfield has an instance name of captions and your txt variable is caption.[/edit]
ahhh! it worked! thank you so much… I will tinker around with it to see if I can make it change with the nav buttons… Any suggestions on where to start?
It should work.
Make sure your txt file is named mycaption.txt, your variable inside the txt file is caption=blablabla and you textfield instance name is captions
I hope I don’t bother you with all my n00b questions, but I have run into another stumbling block… Using this code:
//loads in the caption for each picture
[AS]loadText = new loadVars();
loadText.load(“mycaption.txt”);
loadText.onLoad = function() {
captions.text = this.caption1;[/AS]
This works fine, but I want to assign a variable called “whichcap” that will be an integer. My problem is that I don’t know how to add the variable into the last line… I have tried:
captions.text = this.caption1+whichcap, but it only displays a zero…
heh… let me try again… I have a collection of pictures that are in different categories (camping, concerts, etc). For the sake of the viewer to the website, I would like to have a text box with a caption explaining each picture. The problem is, I can get it to pull from the text file, but not while I navigate the pictures (1-15). I would like to have a caption load up with the first picture, and then change to a different caption as I navigate the pictures… Clear as mud?