I have a httpservice that returns xml data.
<mx:HTTPService id="httpService" url="data/Software.xml" resultFormat="e4x" result="httpResult_handler(event)" fault="Alert.show('XML Data Error')" />
I also have a datagrid using the returned data and also passing it to the renderer which works perfect.
<mx:DataGrid id="myDG"
dataProvider="{httpService.lastResult.item}"
headerHeight="0"
editable="false"
width="100%" height="100%"
rowHeight="50"
itemClick="switchView(myDG.selectedItem.name);">
<mx:columns>
<mx:DataGridColumn itemRenderer="com.xd.components.renderers.SoftwareListRenderer" />
</mx:columns>
</mx:DataGrid>
For each result in the xml data i have some code that creates a new panel() and renderer.
private function viewstack_addChild(name:String):void {
var p:Panel = new Panel();
p.id = name;
p.name = name;
p.title = name;
p.percentWidth = 100;
p.percentHeight = 100;
var randColor:uint = Math.random() * 0xFFFFFF;
p.setStyle("backgroundColor", randColor);
var pR:PageListRenderer = new PageListRenderer();
var data:Object;
//Do something to get the data to be displayed;
pR.data = PageListRenderer;
p.addChild(pR);
myViewStack.addChild(p);
}
However im not able to use the same {data.name} in this renderer as i do in the datagrid renderer. Instead i get "undefined" for each field... How would i go about passing the {httpService.lastResult.item} to the page renderer also?
EDIT: Changes made..
This is the httpservice result handler.
private function httpResult_handler(evt:ResultEvent):void {
if (evt.result.software.item) {
data = XML(evt.result).descendants("item");
var item:Object = data;
for each(item in data) {
viewstack_addChild(item.name);
}
}
}
I have also tried..
private function httpResult_handler(evt:ResultEvent):void {
if (evt.result.software.item) {
data = httpService.lastResult.item;
var item:Object = data;
for each(item in data) {
viewstack_addChild(item.name);
}
}
}
I also changed the pR.data = data in the viewstack_addChild function. I am getting the information in the datagrid still, and i am getting the data on each page rendered however each page has the same information (the first result) instead of each result for each page...