Flex: Using list as repeater... how do I pass information from the dataprovider to the custom module being called?
When using a List component, instead of a Repeater, how do I transfer a value from the dataprovider to the itemRenderer?
For example, I have an array collection (projectsAC) that contains arrays with the following structure:
projectsAC(
0:
Array(
0:number
1:string
2:string
3:string
4:XMLList
)
1:
Array(
0:number
1:string
2:string
3:string
4:XMLList
)
Ect.....
)
I use this array collection as the data provider and a custom module for the item renderer.
How do I access the array values from within the module? I've got the following so far:
<mx:List id="directorsPrepList" dataProvider="{projectsAC}" itemRenderer="modules.project" />
Here's what my projects module looks like right (just for testing purposes)
<?xml ve开发者_如何学JAVArsion="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:Scheduler="modules.*" layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
[Bindable] public var allData:Array = data as Array;
private function init():void
{
Alert.show(String(allData[0]));
}
]]>
</mx:Script>
</mx:Module>
The program stalls during it's initialization... see anything wrong?
how do I transfer a value from the dataprovider to the itemRenderer?
The list class does this automatically. Each itemRenderer has a data property. And your dataProvider's object is set as part of that data property.
It looks like, given your dataProvider, you are passing each individual the renderer an array. If such is the case, you will have to create your own renderer. It looks like you've done that (modules.project), but you didn't show us the code.
To make the itemRenderer update itself whenever the data updates, you'll have to either override the set data method or listen to the dataChange event.
精彩评论