-
1. Re: How do I use an itemrenderer with array from actionscript???
Flex harUI Aug 9, 2010 1:31 PM (in response to craneium)Var arr:Array = [];
arr.push();
...
var al:ArrayList = new ArrayList(arr);
list.dataProvider = al;
-
2. Re: How do I use an itemrenderer with array from actionscript???
craneium Aug 9, 2010 1:39 PM (in response to Flex harUI)yeah thats what i thought but the label propority of the check box is not getting populated. the checkboxes come in but without a label on thim.
-
3. Re: How do I use an itemrenderer with array from actionscript???
BhaskerChari Aug 10, 2010 12:15 AM (in response to craneium)Hi craneium,
In your itemRenderer file you need to specify the property to bind fromm your dataprovider which is stored in data object for each itemRenderer...
<mx:CheckBox id="chk" label="{data.label}" />
Here label is one of the property that you have in your dataprovider for each object...you can replace data.label with the text property you want to be displayed..
I Hope you got my point...
If this post answers your question or helps, please kindly mark it as such.
Thanks,Bhasker Chari
-
4. Re: How do I use an itemrenderer with array from actionscript???
craneium Aug 10, 2010 7:08 AM (in response to BhaskerChari)i am still a little confused here is what i have at current state, which is not
working
<fx:Script>
<![CDATA[
public var myarray:ArrayList;
public var returnedarray:Array = ["a","b","c","d","e","f","g","h"];
public var key:String = "label"
public function init():void{
myarray = new ArrayList;
for (var i:int = 0; i<=(returnedarray.length-1); i++){
var myobj:Object = {};
myobj[key] = returnedarray[i].toString();
myarray.addItem(myobj);
}
FileList.dataProvider = myarray;
}
]]>
</fx:Script><s:List id="FileList" x="10" y="99" width="207" height="285" color="#000000" contentBackgroundColor="#FFFFFF" alternatingItemColors="[#ffffff,#eadee0]" borderVisible="true">
<s:itemRenderer>
<fx:Component>
<s:CheckBox label="{myarray.label}"/>
</fx:Component>
</s:itemRenderer>
</s:List>this throughs a unkown item error (myarray)
-
5. Re: How do I use an itemrenderer with array from actionscript???
MarkTaylor46 Aug 10, 2010 8:34 AM (in response to craneium)Use data.label not myarray.label. Data is passed to an item renderer via data object (which in turn gets sourced from your dataprovider - in your case myarray).
regards,
Mark.
-
6. Re: How do I use an itemrenderer with array from actionscript???
craneium Aug 10, 2010 8:42 AM (in response to MarkTaylor46)I am still getting and error (1120: Access of undefined property; data.)
<s:List id="FileList" x="10" y="99" width="207" height="285" color="#000000" contentBackgroundColor="#FFFFFF" alternatingItemColors="[#ffffff,#eadee0]" borderVisible="true">
<s:itemRenderer>
<fx:Component>
<s:CheckBox label="{data.label}"/>
</fx:Component>
</s:itemRenderer> -
7. Re: How do I use an itemrenderer with array from actionscript???
MarkTaylor46 Aug 10, 2010 9:04 AM (in response to craneium)your s: list has no dataProvider you need to add one. I think that's why.
Regards, Mark.
oops - just noticed ur doing it in actionscript instead of mxml. i presume your init function is invoked on creationcomplete event? try adding a breakpoint in the item renderer and see what it being passed in.
-
8. Re: How do I use an itemrenderer with array from actionscript???
craneium Aug 10, 2010 9:13 AM (in response to MarkTaylor46)man this cannot be this hard, still error 1120.
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:ArrayList id="myarray">
<fx:Object label="File Items Here"/>
</s:ArrayList></fx:Declarations>
<s:List id="FileList" dataProvider="{myarray}" x="10" y="99" width="207" height="285" >
<s:itemRenderer>
<fx:Component>
<s:CheckBox label="{data.label}"/>
</fx:Component>
</s:itemRenderer>
</s:List> -
9. Re: How do I use an itemrenderer with array from actionscript???
MarkTaylor46 Aug 10, 2010 9:53 AM (in response to craneium)change your code as shown below and it works. Use an external renderer instead of an inline one.
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
public var myarray:ArrayList;
public var returnedarray:Array = ["a","b","c","d","e","f","g","h"];
public var key:String = "label"
public function init():void{
myarray = new ArrayList();
for (var i:int = 0; i<=(returnedarray.length-1); i++){
var myobj:Object = {};
myobj[key] = returnedarray[i].toString();
myarray.addItem(myobj);
}
FileList.dataProvider = myarray;
}
]]>
</fx:Script>
<s:List id="FileList" x="10" y="99" width="207" height="285" color="#000000" contentBackgroundColor="#FFFFFF" alternatingItemColors="[#ffffff,#eadee0]" borderVisible="true" itemRenderer="myItemRenderer">
</s:List>
</s:WindowedApplication>then create "myItemRenderer" in the same folder....
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<s:CheckBox label="{data.label}"/>
</s:ItemRenderer>I hope this is what you were expecting.
Regards,
Mark.
-
10. Re: How do I use an itemrenderer with array from actionscript???
craneium Aug 10, 2010 11:48 AM (in response to MarkTaylor46)thank you, thats right on.




