# Get links from an external textfile?

**URL:** <https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391>\
**Category:** flash\
**Created:** [August 13, 2003, 8:39am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391 "2003-08-13T08:39:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattiasn](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mattiasn](https://forum.kirupa.com/u/mattiasn)\
**Post date:** [August 13, 2003, 8:39am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/1 "2003-08-13T08:39:09Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2003, 8:59am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/2 "2003-08-13T08:59:03Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2003, 9:15am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/3 "2003-08-13T09:15:52Z")

</div>

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

THANKS!!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2003, 9:18am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/4 "2003-08-13T09:18:42Z")

</div>

😛

No problem. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2003, 9:58am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/5 "2003-08-13T09:58:02Z")

</div>

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 🙂  
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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 13, 2003, 7:39pm UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/6 "2003-08-13T19:39:46Z")

</div>

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]  
=)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 5:32am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/7 "2003-08-14T05:32:10Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 5:34am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/8 "2003-08-14T05:34:30Z")

</div>

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

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

[EDIT]Probably you’re trying to load progressive JPEG?  
[http://www.macromedia.com/support/flash/ts/documents/cant\_load\_jpg.htm[/EDIT]](http://www.macromedia.com/support/flash/ts/documents/cant_load_jpg.htm%5B/EDIT%5D)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 6:32am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/9 "2003-08-14T06:32:13Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 6:36am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/10 "2003-08-14T06:36:25Z")

</div>

Yessss! Now it works!

Can I call you genious? 😉

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 14, 2003, 6:39am UTC](https://forum.kirupa.com/t/get-links-from-an-external-textfile/28391/11 "2003-08-14T06:39:21Z")

</div>

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

And you’re welcome. =)
