How to load dynamic text according to dynamic image?
Hello all,
I want to make this artist portfolio (ie: a slide show) and I have found a tutorial that showed me how to dynamically load images in an empty movie clip.
Now, I'd like to attach a description for each images and I'd like to keep it dynamic. So, I imagine a folder with one text per image, having a name can can be incremented or decremented (description1.txt, description2.txt, and so on)
and I guess it's a matter of having a recognition of which image we're on in order to load the corresponding text...
Also, I was wondering, can I add html tag in the txt file in order to have some sort of formatting to the output text?
You can create a function that loads
both the text
and the image
depending on a variable i.
For example:
code:
function myFunction(i)
{
// load image i:
my_mc.loadMovie("imagem" + i + ".jpg");
// load text i:
var my_lv = new LoadVars();
my_lv.onLoad = function()
{
// show text i
};
my_lv.load("text" + i + ".txt");
}
I see what you're saying, but the thing is that I already have a bit of code written that it took me quite a while to understand and get working. And I'm almost terrified at the idea of starting from scratch again.
here's the code I have, maybe it's just a matter of one more line somewhere in there!!!
(square = empty MC into which images load)
(mypic = variable for the images)
You can have another movie clip with the text field, or you can have the text filed on the same timeline as the empty movie clip you load the pictures into.
yes I see. But I'm still trying to figure out how to create the object that will recognize which image is loaded and that will load the right text.
Do I use "loadMovie" to load text as well or is there another better function? I'm sorry, I don't understand much of your example... I'm sure there are some elements in there that I must use, but I have a real hard time to figure out what is what and what does what...
any pointers (maybe some keywords on which I could search)?
thanks
Last edited by zap danger; 09-15-2005 at 11:13 AM.
Reason: new idea
I think I'll be able to understand this and adapt it to my project. I don't know if I'll have to forget about the fade in and fade out, but it's not that important.
I was able to make something good out of your example. Thanks.
I would like to add a little feature, and I wonder if you could help me just a bit more. I want to make the «next» button jump to slide 1 when the user is on the last slide and the other way around when the user is on slide 1 (go to the last slide when clicking «previous»)
I know this would have to be done in the button object, and I have a little idea how, but I feel I your help would get me on the right track right away.
ah, yes of course the condition!!!
thanks again, that did it.
Only I have one more question, if you don't mind. I noticed at the begining, you define the function : myFunction(i). I understood (hopefuly right) that this function is what make the slide go forth or back. But I don't quite understand how it works. Also I wonder if the (i) refers to the variable -i- that was set. And finaly, I was wondering why this function is called back in the btn object, especially in the else statement :
Code:
else
{
i = total;
myFunction(i);
}
isn't just - i = total; - enough to make it go there or is it in fact the myfunction(i); that makes it go there??? I mean without it, it would only set -i - equal to the total variable and stop (do nothing more)...