# Loading JPEGs from a textfile

**URL:** <https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644>\
**Category:** flash\
**Created:** [August 28, 2003, 11:55pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644 "2003-08-28T23:55:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cali92](https://avatars.discourse-cdn.com/v4/letter/c/b19c9b/32.png) [@Cali92](https://forum.kirupa.com/u/Cali92)\
**Post date:** [August 28, 2003, 11:55pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/1 "2003-08-28T23:55:34Z")

</div>

Hi everybody. First post, so i’m a little imbarassed …  
My need is easily described  
In my movie I have :

- MC\_Menu (a movieclip with buttons inside)
- MC\_TextBoxes (a movieclips containing all my textboxes filled  
with data loaded from a textfile)

I need to have a space (probably a new movieclip) to be filled by a JPEG image which url is contained in the textfile.

In other words I’d like to have :

varTitle=Title Of The Section&VarText=All the text I need to write in the ‘lesson’&varImage1=“lesson1.jpg”

in my textfile …

Anyone can help ???

Thanks a lot…

Carlo

---

<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 29, 2003, 12:08am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/2 "2003-08-29T00:08:54Z")

</div>

You will have to put in a different movieClip (called ‘container’ for now) and plop it on the stage. After the code that loads in your text, add:

```auto

_root.container.loadMovie("lesson1.jpg");

```

You could load in all the variables and direct them where to go, but that gets complicated - this is an easier solution for you.

BTW Welcome to the forum!!🙂

---

<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 29, 2003, 12:34am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/3 "2003-08-29T00:34:31Z")

</div>

Thank you for your answer.  
The purpouse of the application is giving some students a kind of ‘step by step’ lesson made with FlashMX.

So, for each part of the lessons I’ll have a few variables, as  
Title, Text, Image1, Image2, Movie1, Movie2 and so on (they could virtually be as many as I need …).  
My idea was to include all variables value in a text file.

For example, the images are linked to sites …  
I’m looking for the chance to keep everything as a variable outside the Fla.  
It could give me the ‘power’ to change everything so that my graphic interface is only a ‘graphic container’ for ALL my contents.

My fla is too big to be attached … :sigh:

Did I explain my question clearly ?

Carlo

---

<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 29, 2003, 6:52am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/4 "2003-08-29T06:52:31Z")

</div>

Create a new, empty movieclip (CTRL+F8), drag it from the library (F11) to the stage, and give it the instance name image for example.

Now, place that movieclip inside another movieclip, which I’ll give the instance name container in this example. Once placed inside, place it where you want the image to load. You can easily do that by choosing Edit in Place when opening container, that way all the content will still be visible, so you can see where to put it.

Now, apply this code to container:

[AS]  
onClipEvent(load){  
lv = new loadVars();  
lv.onLoad = function(success){  
if (success){  
image.loadMovie(this.varImage1)  
} else {  
trace(“Failed to load textfile”);  
}  
}  
lv.load(“textfile.txt”)  
}  
[/AS]

… where varImage1 is the variable from the textfile that contains the path to the image. If this path is incorrect, the jpg will not load. And, make sure your jpgs aren’t progressive. Flash can’t handle progressive jpgs.

---

<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 29, 2003, 7:11am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/5 "2003-08-29T07:11:11Z")

</div>

Thanks a lot, it was very clear.  
Now, other 2 questions :

1. Can I use that code to load any kind of file (JPEGS, SWFs, Video) ?

2. The schema of my movie is :

SCENE1 contains MC\_menu, MC\_textboxes and MC\_Container.

what I have to gain is that from a btn contained in MC\_Menu I have to load data (text) into the textboxes of Mc\_textboxes and the file into the MC\_Image of MC\_Container.

Actually on Button1, contained in MC\_Menu, I have this code :

## Actionscript :

```
_root.testi.gotoAndStop(2);
loadVariables("testo1.txt", "_root.testi");

```

* * *

where ‘testi’ is the instance name of the MC containing the textboxes.

So, if I want to load the image contained in my testo1.txt (called varImage1) in the image movieclip, contained in the container movieclip, the code should be something lik :

## Actionscript :

## onClipEvent(load){ lv = new loadVars(); lv.onLoad = function(success){ if (success){ \_root.container.image.loadMovie(this.varImage1) } else { trace(“Failed to load textfile”); } } lv.load(“textfile.txt”) }

Or what ?

Thanks in advance .

Carlo

---

<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 29, 2003, 7:23am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/6 "2003-08-29T07:23:47Z")

</div>

You want it to load when that button is clicked right ?

---

<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 29, 2003, 8:58am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/7 "2003-08-29T08:58:17Z")

</div>

No, it should load the image as I left-click to load text …

Why the question ?

---

<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 29, 2003, 9:02am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/8 "2003-08-29T09:02:06Z")

</div>

Left click on the button ?? This is why I’m confused:

> 

what I have to gain is that from a btn contained in MC\_Menu I have to load data (text) into the textboxes of Mc\_textboxes and the file into the MC\_Image of MC\_Container.

So I suppose you want to load on left click on that button …

---

<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 29, 2003, 9:31am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/9 "2003-08-29T09:31:43Z")

</div>

Yes that’s right …

---

<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 29, 2003, 9:56am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/10 "2003-08-29T09:56:49Z")

</div>

Ah I see, you thought that I thought you wanted it to load when the button was rightclicked, because of this sentence:

> You want it to load when that button is clicked right ?

I meant “right ?” in the way of “correct ?”. But anyways. Place this on your button:

[AS]  
on(release){  
\_root.testi.gotoAndStop(2);  
lv = new loadVars();  
lv.onLoad = function(success){  
if (success){  
\_root.textboxes.textF1.html = 1  
\_root.textboxes.textF2.html = 1  
\_root.container.image.loadMovie(this.varImage1)  
\_root.textboxes.textF1.htmlText = this.varTitle  
\_root.textboxes.textF2.htmlText = this.varText  
} else {  
trace(“Failed to load textfile”);  
}  
}  
lv.load(“textfile.txt”)  
}  
[/AS]

To have it load the image to \_root.container.image. It’s the same actually, only with an on handler instead of the onClipEvent handler. I am supposing there are several textfields contained within the movieclip with the instance name textboxes. I named two of those textfields textF1 and textF2 in this example. I’m not sure if your instance names are like MC\_Container or just container, but you can always change it in the AS 🙂 I used varTitle and varText as vars from the textfile.

---

<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 29, 2003, 1:26pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/11 "2003-08-29T13:26:21Z")

</div>

Thanks a lot for the last answer and sorry for my misunderstanding ‘right’ … 🙂 !!

I only get this problem : when I preview (CTRL+ENTER) my movie,  
it returns me the message :

Error opening : and the name and path of the file …  
I have checked the path and it’s allright (same dir as the swf) .  
Even if I change the object to load ( I tried another jpg, or an swf file), the error is the same.

Can you help me checking this ?

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 29, 2003, 1:33pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/12 "2003-08-29T13:33:25Z")

</div>

That’s funny, if the image is there it should load … Are you absolutely sure the paths are correct ? We’re talking about the paths you specified in the textfile…

---

<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 29, 2003, 2:02pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/13 "2003-08-29T14:02:44Z")

</div>

yes …  
the image is :

varImage1=ciccio.jpg

with the & at the end of the varText=text …

---

<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 29, 2003, 2:05pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/14 "2003-08-29T14:05:23Z")

</div>

Well yeah there’s nothing much I can do without viewing the folder, the fla and the textfile …

---

<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 29, 2003, 8:04pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/15 "2003-08-29T20:04:53Z")

</div>

OK, you can find them here :

[http://www.calibraclub.it/public/dynamicimage.zip](http://www.calibraclub.it/public/dynamicimage.zip)

It will contain :

1- Main Fla  
2- All the text files I use  
3- The image

I will zip the whole folder, so it wll be as it is.

Make me know when you’ll find something… I think it will be the usual dummy error … eheheh

---

<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 29, 2003, 8:19pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/16 "2003-08-29T20:19:59Z")

</div>

‘The page cannot be found’

---

<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 29, 2003, 8:35pm UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/17 "2003-08-29T20:35:33Z")

</div>

Ok, sorry … I wrote a thing, then I’ve been on the phone talkin about other things, then posted on the site a file with another name … ooops…

the file is :

www.calibraclub.it/public/flash\_prove.rar

It’s there …  
thank you a lot !!!

---

<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 30, 2003, 6:25am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/18 "2003-08-30T06:25:41Z")

</div>

The RAR appears to be empty :-\

---

<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 30, 2003, 8:50am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/19 "2003-08-30T08:50:32Z")

</div>

I tried to dl from the site … it’s everything inside …  
how can it be ?

ok,ok, now I put everything there : this is the path :

www.calibraclub.it/public/imaflash/

and the files are :

ciccio.jpg  
introduzione.txt  
testo1.txt  
testo2.txt  
text1.fla

hoping …

🙂

Carlo

---

<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 30, 2003, 8:56am UTC](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644/20 "2003-08-30T08:56:30Z")

</div>

Directory Listing Denied  
This Virtual Directory does not allow contents to be listed.

:-\

[Next page](https://forum.kirupa.com/t/loading-jpegs-from-a-textfile/29644.md?page=2)
