# "Parse" of the array

**URL:** <https://forum.kirupa.com/t/parse-of-the-array/7113>\
**Category:** flash\
**Created:** [October 24, 2002, 1:45am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113 "2002-10-24T01:45:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![waffe](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@waffe](https://forum.kirupa.com/u/waffe)\
**Post date:** [October 24, 2002, 1:45am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/1 "2002-10-24T01:45:34Z")

</div>

All right, it’s getting hot in here!

I load an array from a txt/asp/php ect… file into my fla.

The file looks like this:

216|net.5.mp3|world  
& 214|rock.net.3.mp3|Family  
& 217|net.6.mp3|world  
& 218|net.7.mp3|rap  
& 219|net.8.mp3|rock  
& 212|net.1.mp3|metal  
& 215|net.4.mp3|slow jam  
& 213|net.2.mp3|techno

Now in the next step I want to use the values of the selected listbox that correlate with the loaded array.

onChange = function ()  
{ if (combobox.getValue() == “The 1st value of the array”)  
{screen.loadSound(“The 2nd value of the array”, true);}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 7:24am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/2 "2002-10-24T07:24:35Z")

</div>

Well, how did you put the data in the listbox exactly?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 7:39am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/3 "2002-10-24T07:39:52Z")

</div>

loader = new LoadVars();  
loader.onLoad = function(){  
loader.load (thefile.asp)

I am at home now and I cant rember the code I used, but the list box is useing a loop function that reads the numer of strings and labels them song1,song2,song3 ect…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 7:42am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/4 "2002-10-24T07:42:45Z")

</div>

This won’t put it in the listbox… 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 9:00pm UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/5 "2002-10-24T21:00:53Z")

</div>

var list = new Array();  
loader = new LoadVars();  
loader.onLoad = function() {

var n = 1;  
for (var i in loader) {  
trace(i+": “+this\*);  
// split the label from the data  
var list = this\*.split(”|");  
// fill the combobox  
combobox.addItem("Read profile “+n+” "+list[0], [list[1]]);  
n = n+1;  
}  
};  
loader.load(“[http://www.file.asp](http://www.file.asp)”);

Hope this helps.

:rambo:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2002, 10:34pm UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/6 "2002-10-24T22:34:39Z")

</div>

by using “&” in the variable file, the loadvars object is interpreting it as a list of variables in name value pairs. but there are no “=” so essentailly, it’s a list of variable names, with no values attached.

you could use “=” in the file.asp, or, i think your existing code will work if you reference the variable name rather than its value (since it has no value).

note where i’ve written “i” instead of “this\*”:

```auto

loader = new LoadVars();
loader.onLoad = function() {
   var list,n;
   for (var i in loader) {
      n++;
      list = i.split("|");
      combobox.addItem("Read profile "+n+" "+list[0], list[1]);
   }
};
loader.load("http://www.file.asp");

```

are you doing anything with list[2]? you seem to have three components to each variable.

i might also add that it’s a little unorthodox to be splitting the variable name. it’s only flashes permissive casting that lets you get away with that.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 25, 2002, 6:14am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/7 "2002-10-25T06:14:36Z")

</div>

> note where i’ve written “i” instead of “this\*”:  
> I don’t understand, Supra… :cyclops: :q:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 25, 2002, 9:37am UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/8 "2002-10-25T09:37:34Z")

</div>

All is working well except the last part of my original code.

onChange = function ()  
{ if (combobox.getValue() == “The 1st value of the array”)  
{screen.loadSound(“The 2nd value of the array”, true);}

When I try something like;

onChange = function ()  
{ if (combobox.getValue() == “list[1]”)  
{screen.loadSound(“list[1]”, true);}

I get a error message saying

Error opening URL “list[1]”.

It should not say list[1], it should give the 2nd value of the array.

The loadSound command is asking for a url. How do I show it the array.  
:pirate:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 25, 2002, 7:32pm UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/9 "2002-10-25T19:32:53Z")

</div>

waffe - no quotes

ily - with this (moderately whacked, but hey, if it ain’t broke…) method of importing data it’s the _names_ of the variables that contain the data, as opposed to their values. thus in a for(i in this) loop, i contains the relevant data as opposed to this\*.

is that what you were getting at?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 25, 2002, 8:12pm UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/10 "2002-10-25T20:12:35Z")

</div>

If i contains the relevant data as opposed to this\*, then how do I plug in the their values into the loadSound command?

onChange = function ()  
{ if (combobox.getValue() == “i[1]”) ???  
{screen.loadSound(“i[1]”, true);} ???

If I do not use quotes in  
{screen.loadSound(i[1], true);}

The loadSound command read nothing for the url field.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 25, 2002, 9:12pm UTC](https://forum.kirupa.com/t/parse-of-the-array/7113/11 "2002-10-25T21:12:42Z")

</div>

3 days of questions, tutorials and the answer mine!

The answer to my last question is  
onChange = function () { screen.loadSound(combobox.getSelectedItem().data, true);};

The whole time I was not using combobox in my code.:x

Thank you [kirupa.com](http://kirupa.com) for all your support.

Bill
