# Load Image From Text File

**URL:** <https://forum.kirupa.com/t/load-image-from-text-file/164141>\
**Category:** flash\
**Created:** [September 28, 2005, 8:05pm UTC](https://forum.kirupa.com/t/load-image-from-text-file/164141 "2005-09-28T20:05:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danlanman](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@danlanman](https://forum.kirupa.com/u/danlanman)\
**Post date:** [September 28, 2005, 8:05pm UTC](https://forum.kirupa.com/t/load-image-from-text-file/164141/1 "2005-09-28T20:05:58Z")

</div>

I am a new member and fairly new to AS but I am hoping that someone might be able to help me out. I am loading a image into a MC from a text file and I have got it working okay but now I would like to make it into a function. I have code that I though would work, but the image is no longer loading.

This is the working code

```php
 loadText = new LoadVars();
loadText.load("data.txt");
loadText.onLoad = function() {
	 name.text = this.name;
	 loadMovie(this.image, empty_MC);
};

```

Contents of the data.txt file

```php
 &name=Dan
&image=1.jpg 

```

Non-working function

```php
 function test() {
	 loadText = new LoadVars();
	 loadText.load("data.txt");
	 loadText.onLoad = function() {
		 name.text = this.name;
		 loadMovie(this.image, empty_MC);
	 }
}; 

```

I am pretty sure that it has something to do with the loadText.onLoad = function() { line.  
Any ideas?

Thanks,  
Dan
