Using Loaded Variables For Loading Images

[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]

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]

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

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.

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

Thanks!!! :thumb:

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

LOL!! Nice one Dan! :beam:

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

picURLS=pic1,pic2,pic3,pic4

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

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! :smiley:
made my day :beam:

12 pictures will be loaded.

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

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

the FLA in the attached zip is blank :trout:

Updates .zip file.

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

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

:thumb:

stupid me

The image should be loaded into:

_root.mainHolder.picLoader1.picHolder
_root.mainHolder.picLoader2.picHolder
_root.mainHolder.picLoader3.picHolder

and so on. . . . .

So if

i = 1;

Then:

mainHolder["picLoader" + i].picHolder

Is the same thing?

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

*Originally posted by telekinesis *
Is the same thing?
exactly! :stuck_out_tongue:

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

The file worked fine here, It loaded in the images :slight_smile:

Could you post the .fla?

http://www.syntheticorange.com/dan/

http://www.danalu.com/ebay_auctions2.html

Very weird, not working on my side. :frowning:

**** world lol!

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 :wink:

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

Just posting an update.

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/ 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.