Load files

Hi, I am trying to load data from a file and put it in a comboBox. The coding I am using should work on platforms like Java and C, but I can’t understand why on flash (since the coding style is like Java) it doesn’t want to work. First of all i created a text file called “sections.txt” and the data inside it is as follows:

[font=Courier New]&Ammount=3[/font]
[font=Courier New]&ele1=“Hello 1”[/font]
[font=Courier New]&ele2=“Hello 2”[/font]
[font=Courier New]&ele3=“Hello 3”[/font]

Then I used the following code to extract the data from the file:

[font=Courier New]loadText = [color=navy]new[/color] [color=navy]loadVars/color;[/font]
[font=Courier New]loadText.[color=navy]load/color;[/font]

[font=Courier New]loadText.[color=navy]onLoad/color = [color=navy]funtion/color{[/font]

[font=Courier New][color=slategray]// int(this.Ammount) is used to parse [/color][/font]
[font=Courier New][color=slategray]// string “3” to an integer number.[/color][/font]
[font=Courier New][color=navy]for[/color](i=1; i < [color=navy]int/color; i++){[/font]

[font=Courier New][color=slategray]// populating comboBox with elements.[/color][/font]
[font=Courier New][color=navy]_root[/color].combo.[color=navy]addItem/color[/font]
[font=Courier New][color=slategray]// this.ele+""+i should become this.ele1 and thus load[/color][/font]
[font=Courier New][color=slategray]// the data found in the section &ele1, i.e. - “hello 1”[/color][/font]

[font=Courier New]}[/font]

[font=Courier New]}[/font]

The problem with the above code is that [font=Courier New][color=navy]int/color[/font] is returning a
0 (Zero) and thus the loop never starts. And when I tried to inser a fixed number (ex: 3) all that is inserted in the combo bix is the value of [font=Courier New][color=navy]i[/color][/font] and not [font=Courier New][color=navy]this[/color].ele+[color=blue]""[/color]+i.[/font]

I can’t understand what is the problem since the concatination seems quite clear for me. I cant use [font=Courier New][color=navy]XML/color[/font] class coz i am loading from another flash file and it seems this class does not suport that, coz it loads nothing. I thought whether there is any way to travers the text file like [font=Courier New]this.[color=navy]next[/color][/font][color=navy] [/color](i know this doesn’t work).

Thanks to all in advance, And i’ll be very greatfull for any answers about the topic. Thanks!

Ok, At least I found the problem with the [font=Courier New][color=navy]XML/color[/font] classes. All i have to make is to remove the [font=Courier New][color=navy]_root[/color][/font] whenever i am calling the comboBox.

i.e. instead of [font=Courier New][color=navy]_root[/color].combo.[color=navy]add/color;[/font]
it comes just
combo.[color=navy]add/color;

:slight_smile: