# Reading text file with multiple variables

**URL:** <https://forum.kirupa.com/t/reading-text-file-with-multiple-variables/317671>\
**Category:** flash\
**Created:** [December 29, 2010, 4:28pm UTC](https://forum.kirupa.com/t/reading-text-file-with-multiple-variables/317671 "2010-12-29T16:28:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dplows](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@dplows](https://forum.kirupa.com/u/dplows)\
**Post date:** [December 29, 2010, 4:28pm UTC](https://forum.kirupa.com/t/reading-text-file-with-multiple-variables/317671/1 "2010-12-29T16:28:51Z")

</div>

When I open a text document containing 1 string of a Base64 Encoded Image, it works fine:

```auto

import flash.display.Loader;
import flash.utils.ByteArray;
import formatter.Base64;

var imgB64Str:String=""; 
var ld:Loader=new Loader();

var my_req:URLRequest = new URLRequest("horses.img");
var my_loader:URLLoader = new URLLoader();

my_loader.addEventListener(Event.COMPLETE, loadText);
my_loader.load(my_req);

function loadText(e:Event):void{
    // set string variable to loaded text
    imgB64Str = my_loader.data;
    // position, decode & display
    ld.x = ld.y = 50;
    ld.loadBytes(Base64.Decode(imgB64Str));
    addChild(ld);
}

```

The image displays and that’s great, but I need to display multiple images; therefore, I used the standard format: var1=value1&var2=value2&…  
(In reality, the values are the huge base64 strings.)

Then I just needed to add “my\_loader.dataFormat = URLLoaderDataFormat.VARIABLES;” since the format of my source changed.

**The thing that bugs me is that I’m tracing the imgB64Str after I set it and it traces fine (just like the other version). And from then on I’m not doing anything different!**

See my comments for things I did different…

```auto

import flash.display.Loader;
import flash.utils.ByteArray;
import formatter.Base64;

var imgB64Str:String=""; 
var ld:Loader=new Loader();

var my_req:URLRequest = new URLRequest("images.img"); // CHANGED: source file, due to new format
var my_loader:URLLoader = new URLLoader();
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES; // CHANGED: formatting input from text to variables

my_loader.addEventListener(Event.COMPLETE, loadText);
my_loader.load(my_req);

function loadText(e:Event):void{
    imgB64Str = my_loader.data.image1; // CHANGED: instead of grabbing whole data, grabbing the image1 variable
    trace(imgB64Str); // CHANGED: traces fine!
    // same as other from here down!
    ld.x = ld.y = 50;
    ld.loadBytes(Base64.Decode(imgB64Str));
    addChild(ld);
}

```

It runs with no errors, but the image no longer displays.

What’s the deal?!? :eek:

Any help is greatly appreciated.
