# Using Loaded Variables For Loading Images

**URL:** <https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733>\
**Category:** flash\
**Created:** [October 22, 2003, 10:17pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733 "2003-10-22T22:17:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![telekinesis](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@telekinesis](https://forum.kirupa.com/u/telekinesis)\
**Post date:** [October 22, 2003, 10:17pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/1 "2003-10-22T22:17:06Z")

</div>

[size=1] **Objective:** Load variables from a text file named [color=red]picData.txt[/color] into a movie clip on the root timelines with an instance name of [color=blue]mainHolder[/color]. Then I want to load an image that is defined as a variable in the [color=red]picData.txt[/color] file I load.

**Problem:** After loading the variables from the [color=red]picData.txt[/color] text file into a movie on the root timeline with an instance of [color=blue]mainHolder[/color] the variables could not be accessed. I tried [color=gray]trace();[/color] and everything.

**Note:** The [color=red]picData.txt[/color] is located in the same directory as the Flash file.[/size]

**[color=red]picData.txt[/color]**

```auto
picURL1=http://www.danalu.com/images/something.jpg&picURL2=http://www.danalu.com/images/somethingElse.jpg&picURL3=http://www.danalu.com/images/somethingElseAgain.jpg

```

**[color=blue]Frame 1:[/color]**

```auto
loadVariables("picData.txt", "_root.mainHolder");
mainHolder.picHolder1.loadMovie(picURL1);
mainHolder.picHolder2.loadMovie(picURL2);
mainHolder.picHolder3.loadMovie(picURL3);

```

---

<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:** [October 22, 2003, 10:59pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/2 "2003-10-22T22:59:29Z")

</div>

I’ve become more accustomed to using LoadVars() to load in variables, but lemme give this a shot…

You load the variables into the mainHolder clip, so shouldn’t it be something like [AS]mainHolder.picHolder1.loadMovie(\_parent.picURL1);[/AS] Also, loadVariables doesn’t work instantly, you have to wait a while for the variables to get loaded. That is what is good about LoadVars(), it has the ability to use the onLoad event handler so you can check when the variables are loaded and do what you want from there.

I would go more into it, but I have to go now. I will be on tonight so if this doesn’t get solved by then I will see what I can do.

---

<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:** [October 22, 2003, 11:03pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/3 "2003-10-22T23:03:19Z")

</div>

yes, you’ll have to use LoadVars for that… i’ll post the code in a few 🙂

---

<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:** [October 22, 2003, 11:06pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/4 "2003-10-22T23:06:05Z")

</div>

Thanks!!! :thumb:

A funny link for your service:  
[http://www.albinoblacksheep.com/text/aol.php](http://www.albinoblacksheep.com/text/aol.php)

---

<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:** [October 22, 2003, 11:11pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/5 "2003-10-22T23:11:23Z")

</div>

LOL!! Nice one Dan! :beam:

---

<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:** [October 22, 2003, 11:17pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/6 "2003-10-22T23:17:14Z")

</div>

try this  
**[SIZE=1]picData.txt[/SIZE]**

```auto
picURLS=pic1,pic2,pic3,pic4

```

**[SIZE=1]Code on \_root timeline[/SIZE]**

```auto
lv = new LoadVars ();
lv.onLoad = function (success)
{
if(success)
{
var picArray = this.picURLS.split(","); // store each url into an array element
for ( var i=0 ; i<picArray.length ; i++ )
{
// mainHolder.createEmptyMovieClip( "picHolder"+i, i ).loadMovie(picArray*+".jpg");
mainHolder["picHolder"+i].loadMovie(picArray*+".jpg");
}
delete picArray, i
}
else trace("Cannot load file");
}
lv.load("picData.txt");

```

btw, how many pics are you loading?

[edit]

oh my god… what a loser! 😃  
made my day :beam:

---

<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:** [October 22, 2003, 11:20pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/7 "2003-10-22T23:20:42Z")

</div>

12 pictures will be loaded.

---

<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:** [October 22, 2003, 11:22pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/8 "2003-10-22T23:22:43Z")

</div>

ah alright, textfiles should be fine… i was thinking if you’re trying to load too many, xml could be a bit easier to work with =) you don’t need it though

---

<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:** [October 22, 2003, 11:32pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/9 "2003-10-22T23:32:15Z")

</div>

I am still having problems, the images won’t show. This is a project for my work so that you can preview other selected auctions from within an auction, the interface is not done, but I want to know it can work first.

The purpose of being able to change the URL’s and the Item Descriptions is so that who ever takes over my job when I am not there can just edit a .txt file instead of having to use flash.

[http://www.danalu.com/auctions.zip](http://www.danalu.com/auctions.zip)

---

<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:** [October 22, 2003, 11:35pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/10 "2003-10-22T23:35:56Z")

</div>

the FLA in the attached zip is blank :trout:

---

<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:** [October 22, 2003, 11:48pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/11 "2003-10-22T23:48:15Z")

</div>

Updates .zip file.

How would I go about this process in that .fla using a loaded xml document instead of a .txt file?

---

<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:** [October 22, 2003, 11:51pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/12 "2003-10-22T23:51:12Z")

</div>

```auto
// change:
mainHolder["picHolder"+i].loadMovie(picArray*+".jpg");
// to:
mainHolder["picHolder"+i].loadMovie(picArray*);

```

:thumb:

stupid me

---

<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:** [October 22, 2003, 11:53pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/13 "2003-10-22T23:53:13Z")

</div>

The image should be loaded into:

```auto
_root.mainHolder.picLoader1.picHolder
_root.mainHolder.picLoader2.picHolder
_root.mainHolder.picLoader3.picHolder

```

and so on. . . . .

So if

```auto
i = 1;

```

Then:

```auto
mainHolder["picLoader" + i].picHolder

```

Is the same thing?

Does it work for you when you do it on your computer?

---

<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:** [October 22, 2003, 11:57pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/14 "2003-10-22T23:57:56Z")

</div>

> \*Originally posted by telekinesis \*  
> **Is the same thing?**  
> exactly! 😛

Senocular has a good post on associative arrays (see Best of Senocular)

The file worked fine here, It loaded in the images 🙂

---

<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:** [October 22, 2003, 11:58pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/15 "2003-10-22T23:58:27Z")

</div>

Could you post the .fla?

---

<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:** [October 22, 2003, 11:59pm UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/16 "2003-10-22T23:59:32Z")

</div>

[http://www.syntheticorange.com/dan/](http://www.syntheticorange.com/dan/)

---

<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:** [October 23, 2003, 12:03am UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/17 "2003-10-23T00:03:05Z")

</div>

[http://www.danalu.com/ebay\_auctions2.html](http://www.danalu.com/ebay_auctions2.html)

Very weird, not working on my side. ☹

\*\*\*\* world lol!

---

<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:** [October 23, 2003, 1:17am UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/18 "2003-10-23T01:17:44Z")

</div>

lol!.. the images must be hosted on the same server i think… if you want an xml approach, uh, the thing I PMed you should do it 😉

---

<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:** [October 23, 2003, 7:14am UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/19 "2003-10-23T07:14:07Z")

</div>

Fixed… I helped Dan XML-ize it as well.

Just posting an update.

---

<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:** [October 23, 2003, 7:49am UTC](https://forum.kirupa.com/t/using-loaded-variables-for-loading-images/33733/20 "2003-10-23T07:49:42Z")

</div>

Hmm, someone post the final version of this? I’ve kinda been following and am interested to see a completed XML alized. I’ve just started learning some PHP and have a smimilar type thing going on (not in flash though) over at my site… [http://www.dujodu.com/IMAGESCRIPT/](http://www.dujodu.com/IMAGESCRIPT/) basically it’s just a function imgTable(thumbDir,largeDir); and pulls the thumbs out, links to the large, and has a unique description for each.

On that page, i just have the function called twice, once with the thumb directory as the source for the table, and the other as the large directory with the source for the table… just to show how it works. It’s not complete yet, obviously.
