# Display text and image using txt-file

**URL:** <https://forum.kirupa.com/t/display-text-and-image-using-txt-file/328793>\
**Category:** flash\
**Created:** [June 17, 2012, 4:12pm UTC](https://forum.kirupa.com/t/display-text-and-image-using-txt-file/328793 "2012-06-17T16:12:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magnus\_Dyngen](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Magnus\_Dyngen](https://forum.kirupa.com/u/Magnus_Dyngen)\
**Post date:** [June 17, 2012, 4:12pm UTC](https://forum.kirupa.com/t/display-text-and-image-using-txt-file/328793/1 "2012-06-17T16:12:37Z")

</div>

Hi!

In connection with an oral exam, I have been given the task of making a program where a user can choose which knots he has completed using a combo box and a button.

When the user completes a knot, the name of the knot will show up in a data-grid, and an image of the knot will display to the right of the data-grid.

So far this is the code I have:

```auto
import fl.data.DataProvider;
var arrKnots:Array = [
        { label:"Knot 1", picture:"image 1" },
        { label:"Knot 2", picture:"image 2" },
        { label:"Knot 3", picture:"image 3" }
                       ];
                       
cmbKnots.dataProvider = new DataProvider(arrKnots);

btnCompletedKnot.addEventListener("click", AddKnot);
var OverviewOfKnots:Object = {};

function AddKnot(e:Event) {
    var arrKnots:Array = []; 
    var newKnot:Object = cmbKnots.selectedItem;
    OverviewOfKnots[newKnot.label] = {"Your completed knots:": newKnot.label};
    for (var knotname:String in OverviewOfKnots) 
    {
        newKnot = OverviewOfKnots[knotname];
        arrKnots.push(newKnot);
        }
    grdKnots.dataProvider = new DataProvider(arrKnots);
}

```

At least this code works and i do mostly understand it, but it has several problems. No images showing is one of them.  
The main problem however is that the knot-names and images are supposed to be read from an external txt-file, and not directly from the array. I guess I’ll have to push the txt-file’s content into the array somehow, but I have no idea how I can do this, or how I can display the images at all.

The txt-file looks something like this:

```auto
"First knot" image_of_first_knot
"Second knot" image_of_second_knot
"Third knot" image_of_third_knot

```

I’m not sure if I have explained the problem in an understandable way, but if anyone understand, is this something you can help me with?
