PDA

View Full Version : Having issues with the List component


dColumbus
10-03-2007, 02:20 PM
From Flash Media Server I am gathering a list of video's that are available to stream sent to my Flex 2 application. I then take the response (the list) and trace to make sure that it's there:


// if i don't access the "name" property, I don't see anything
trace(response[0].name);


I then loop through the array, and add it to an ArrayCollection (it seems redundant extracting and array and adding it to an array again):

var i:int;
for (i=0; i<response.length; i++)
{
responderArray.addItem(response[i].name);
}


Then I trace the new array to verify that it contains the right information, and attempt to use it as a dataProvider for myList:

trace(responderArray);
myList.dataProvider(responderArray);


It just plain ol' doesn't work. I can't seem to add the information contained in my array (either the original response array, or my newly formed ArrayCollection) to add to myList component.

The Flex error that I keep getting in debug is:
"TypeError: Error #1006: value is not a function."

This just doesn't make sense to me... I would VERY much appreciate some help with this!

box86rowh
10-03-2007, 03:14 PM
From Flash Media Server I am gathering a list of video's that are available to stream sent to my Flex 2 application. I then take the response (the list) and trace to make sure that it's there:


// if i don't access the "name" property, I don't see anything
trace(response[0].name);


I then loop through the array, and add it to an ArrayCollection (it seems redundant extracting and array and adding it to an array again):

var i:int;
for (i=0; i<response.length; i++)
{
responderArray.addItem(response[i].name);
}


Then I trace the new array to verify that it contains the right information, and attempt to use it as a dataProvider for myList:

trace(responderArray);
myList.dataProvider(responderArray);


It just plain ol' doesn't work. I can't seem to add the information contained in my array (either the original response array, or my newly formed ArrayCollection) to add to myList component.

The Flex error that I keep getting in debug is:
"TypeError: Error #1006: value is not a function."

This just doesn't make sense to me... I would VERY much appreciate some help with this!


i usually set the dataprovider with = as in myList.dataProvider = responderArray;

dColumbus
10-03-2007, 04:25 PM
..................

it was just that simple... or heavens sakes!

Thank you for that golden nugget.

drkstr
10-06-2007, 10:31 AM
I then loop through the array, and add it to an ArrayCollection (it seems redundant extracting and array and adding it to an array again):That is redundant, you can just pass an array to the constructor of an ArrayCollection.


var arrayData:Array = [ {label:'Item 1', data:1}, {label:'Item 2', data:2} ];
var dataCollection:ArrayCollection = new ArrayCollection(arrayData);


I usually try avoid adding items directly to the data provider on the first load since there is more overhead in updating the display list for each item.

Best Regards,
...aaron

dColumbus
10-12-2007, 10:49 PM
So i've got everything working except one thing...

I'm looping through as I add the array to the arrayCollection in order to replace some of the object's name:


//loop through the array and add to myList
var i:int;
for (i=0; i<response.length; i++)
{
responderArray.addItem(response[i].name.replace("/streams/_definst_/",""));
}

trace(responderArray);
myList.dataProvider = responderArray;


However, the ".flv" extension still exists in the name and I can't figure out how to replace that as well...

???