header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
gourav
Points:540
Posts:0

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



1
Flash_Guy
Points: 850
Posts:0
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 ?

2
gourav
Points: 540
Posts:0
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>				

3
gourav
Points: 540
Posts:0
10/27/2010 10:18:56 PM



can any one reply how can i call dragExitFun() in given code
thanks

4
gourav
Points: 540
Posts:0
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>                  


5
NileshPawar
Points: 280
Posts:0
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();
 }

6
aaqq
Points: 0
Posts:0
9/2/2011 11:33:46 AM



if itemRender is as file, try this listData.owner.document

7
moszoro
Points: 0
Posts:0
1/24/2012 8:14:08 AM



very fast example:
leftList.dataGroup.getElementAt(0)["dragExitFun"]();

cheers !


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 7+3 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions