Get links from an external textfile?

Hi!
I hope someone can help me with this.

In my flashfile I have a textfield and a button. I want to add information for these from a textfile.

I have managed to get the flash to link in the text from the textfile, but now I’m stuck.

I want the button to pick up the url that it should lead to from the same textfile. Unfortunately I’m more of a designer than a programmer so I am have a problem with this.

This is how you link an URL from the button:

on (release) (
getURL("");
)

Now I want to pick up the url from the textfile (info.txt).
This is what I guess that the textfile must contain, but I’m not sure:
&link=gohere.htm

Now what do I have to do to make this work?

Thanks for your help!

Basically, create a LoadVars object and load the TXT file, then you can access the variable through loadVarsObject.link.

Here’s a quick example:
[AS]// Frame actions:
var info_lv = new LoadVars();
info_lv.load(“info.txt”);
// Button actions:
on (release) {
getURL(info_lv.link);
}[/AS]

Whooohoohoo… it works.
If you wouldn’t have been so far away I would have kissed you =)

THANKS!!!

:stuck_out_tongue:

No problem. :wink:

OK… since you obviously are so great at this…
Might I ask you for help once more…
…else I will be struggling with this for a few more hours I guess :slight_smile:
Say no if I’m taking up too much of your time.

I want to have an image on the page as well, and I want to get the url for the image from the same textfile.

I have created an imageholder that looks like this:

_root.createEmptyMovieClip(“container”,1);
container.loadMovie(“images/image1.jpg”);
container._x = 10 ; container._y = 40 ;

…and now I want to pick the “images/image1.jpg” from the textfile instead. (&image=images/image1.jpg)

I tried like this, but it didn’t work:

var image_lv = new LoadVars();
image_lv .load(“info.txt”);
_root.createEmptyMovieClip(“container”,1);
container.loadMovie(“image_lv.image”);
container._x = 10 ; container._y = 40 ;

Man, I wish I hade a programmers head!

Remove the quotes…
[AS]container.loadMovie(image_lv.image);[/AS]
Also, you don’t need to load the same file twice! And it would be better if you use an onLoad handler; I’d use a dynamic event event handler instead of the static event handler to assign the actions to the Button. In the end, you’d have something like this:
[AS]var info_lv = new LoadVars();
info_lv.onLoad = function(success) {
if (success) {
myButtonInstanceName.onRelease = function() {
getURL(info_lv.link);
};
createEmptyMovieClip(“container”, 1);
container._x = 10;
container._y = 40;
container.loadMovie(this.image);
} else {
// an error has occurred
}
};
info_lv.load(“info.txt”);[/AS]
=)

Hi!
The image won’t show anyway. Don’t know why.

Aaah well, I’ll keep trying to find out what’s wrong…

Weird… the code seems to be fine to me. :-\

If you can’t figure it out, attach the FLA and TXT files… :wink:

[EDIT]Probably you’re trying to load progressive JPEG?
http://www.macromedia.com/support/flash/ts/documents/cant_load_jpg.htm[/EDIT]

Problem: the code is executed before the TXT file has been loaded.
Solution: use an onLoad event handler.
[AS]var image_lv = new LoadVars();
image_lv.onLoad = function() {
createEmptyMovieClip(“container”, 1);
container.loadMovie(this.image1);
container._x = 10;
container._y = 40;
};
image_lv.load(“produkt.txt”);[/AS]

Yessss! Now it works!

Can I call you genious? :wink:

Thanks for all your help and effort. I think I will find my way from here to finish this thing. You have leant me alot!

… It would be a lie, but you can call me genious. :stuck_out_tongue:

And you’re welcome. =)