Call parent function from an itemRenderer
12,780
Solution 1
Try this, using parentDocument
:
<mx:VBox id="vbx_container" paddingBottom="4" paddingLeft="4" paddingRight="4" paddingTop="4" borderStyle="solid"
dropShadowEnabled="true" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
<mx:Canvas width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
<mx:Image id="image" width="100" height="100" source="{data.thumb}" scaleContent="true" maintainAspectRatio="true"
complete="{image_smoothing_handler(event);}" trustContent="true" doubleClick="parentDocument.edit_groups()"/>
</mx:Canvas>
</mx:VBox>
Solution 2
You can reference the outerDocument
like this
<mx:VBox id="vbx_container" paddingBottom="4" paddingLeft="4" paddingRight="4" paddingTop="4" borderStyle="solid"
dropShadowEnabled="true" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
<mx:Canvas width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
<mx:Image id="image" width="100" height="100" source="{data.thumb}" scaleContent="true" maintainAspectRatio="true"
complete="{image_smoothing_handler(event);}" trustContent="true" doubleClick="{outerDocument.edit_groups()}"/>
</mx:Canvas>
</mx:VBox>
Solution 3
Make sure what you are trying to reference is set to a public function or variable.
Solution 4
If you are getting error 1069 and your item renderer is a separate mxml component you may need to use:
parentDocument.parentDocument.functionName();
Related videos on Youtube
Author by
Zeeshan Rang
Updated on April 15, 2022Comments
-
Zeeshan Rang about 2 years
I want to call the parent function called "edit_groups()" from the itemRenderer. The code for my itemRenderer is:
<mx:VBox id="vbx_container" paddingBottom="4" paddingLeft="4" paddingRight="4" paddingTop="4" borderStyle="solid" dropShadowEnabled="true" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" > <mx:Canvas width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" > <mx:Image id="image" width="100" height="100" source="{data.thumb}" scaleContent="true" maintainAspectRatio="true" complete="{image_smoothing_handler(event);}" trustContent="true" doubleClick="{CALL THE PARENT FUNCTION "edit_groups()"}"/> </mx:Canvas> </mx:VBox>
And I call my itemRenderer from an application like:
list_groups_modify.itemRenderer=new ClassFactory(groups.list_groups_modify_item_renderer); <mx:Label text="{data.label}" textAlign="center" maxWidth="60" toolTip="{data.label}"/>
Regards Zeeshan
-
Nick Craver over 14 years@Zeeshan - Sorry wasn't thinking right, try
parentDocument
instead, answer updated. -
Magnus Smith about 14 yearsI thought this would answer my identical problem, but I am getting error 1069 instead. Whilst the compiler lets me through, at run time I am told it cannot find my public function!
-
Magnus Smith about 14 years(My itemrenderer is in a seperate MXML file in Flash Builder 4)
-
Garnet R. Chaney over 2 yearsI also get the exception #1069 upon trying to call the method on the parentDocument. When the renderer is part of an s:List, the parentDocument is pointing at spark.skins.spark.ListSkin.