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:
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:
"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?