10/27/2010 2:01:05 AM
Title:
call function in itemRenderer.
Hi friends,
I want to call a frunction from parent script to itemRenderer script.
for eg:
i have one function in my ItemRenderer that is vbox that is in List now i want to call that function from my main file script.
Thanks in advance
10/27/2010 9:26:17 AM
any function declared inside item renderer is created for each element in the list. this means if you have 10 items then each one will have its own function. Do you want to call a particular function inside a particular item ?
10/27/2010 10:18:19 PM
<fx:Script>
<![CDATA[
public function callIRFun() void{
//dragExitFun()
//i want to call function available in List itemRenderer .
]]>
</fx:Script>
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" paddingTop="110" paddingLeft="50">
<mx:HBox width="100%" height="80%" verticalAlign="middle" horizontalAlign="center">
<mx:VBox height="100%" width="100%" paddingLeft="60" >
<s:List id="leftList" dataProvider="{filterUpcomingWordAC}" borderAlpha="0"
contentBackgroundAlpha="0" color="#f4f4f4" borderVisible="false" labelField="target"
dragEnabled="true" allowMultipleSelection="false"
dragMoveEnabled="true" dragComplete="dragCompleteFun(event)"
>
<s:itemRenderer>
<fx:Component>
<mx:VBox >
<fx:Script>
<![CDATA[
public function dragExitFun()void{
//how can i call this function from main
}
]]>
</fx:Script>
<mx:Button id="btnleftList" fontFamily="Calibri" label="{this.data.target}" dragExit="dragExitFun(event)"
styleName="columnlblLeft" fontWeight="bold" buttonMode="true" width="114.75" height="24.05" />
<mx:Spacer height="10" />
</mx:VBox>
</fx:Component>
</s:itemRenderer>
</s:List>
</mx:VBox>
<mx:VBox horizontalAlign="right" paddingRight="100" height="100%" width="100%" >
</s:Group>
10/27/2010 10:18:56 PM
can any one reply how can i call dragExitFun() in given code
thanks
10/27/2010 10:19:51 PM
Updated code
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
public function callIRFun() void{
//dragExitFun()
//i want to call function available in List itemRenderer .
]]>
</fx:Script>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" paddingTop="110" paddingLeft="50">
<mx:HBox width="100%" height="80%" verticalAlign="middle" horizontalAlign="center">
<mx:VBox height="100%" width="100%" paddingLeft="60" >
<s:List id="leftList" dataProvider="{filterUpcomingWordAC}" borderAlpha="0"
contentBackgroundAlpha="0" color="#f4f4f4" borderVisible="false" labelField="target"
dragEnabled="true" allowMultipleSelection="false"
dragMoveEnabled="true" dragComplete="dragCompleteFun(event)"
>
<s:itemRenderer>
<fx:Component>
<mx:VBox >
<fx:Script>
<![CDATA[
public function dragExitFun()void{
//how can i call this function from main
}
]]>
</fx:Script>
<mx:Button id="btnleftList" fontFamily="Calibri" label="{this.data.target}" dragExit="dragExitFun(event)"
styleName="columnlblLeft" fontWeight="bold" buttonMode="true" width="114.75" height="24.05" />
<mx:Spacer height="10" />
</mx:VBox>
</fx:Component>
</s:itemRenderer>
</s:List>
</mx:VBox>
<mx:VBox horizontalAlign="right" paddingRight="100" height="100%" width="100%" >
</s:Group>
12/3/2010 3:48:56 AM
You have to create an another MXML / AS component of itemrenderer say having name "VBoxRenderer".
public function callIRFun() void{
var rendrerer:VBoxRenderer= leftList.itemRenderer as VBoxRenderer;
rendrerer.dragExitFun();
}
9/2/2011 11:33:46 AM
if itemRender is as file, try this listData.owner.document
1/24/2012 8:14:08 AM
very fast example:
leftList.dataGroup.getElementAt(0)["dragExitFun"]();
cheers !