views:

421

answers:

3

Hi

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 me 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

+1  A: 

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>
Nick Craver
I get an error : Access of undefined property outerDocument
Zeeshan Rang
@Zeeshan - Sorry wasn't thinking right, try `parentDocument` instead, answer updated.
Nick Craver
Thanks alot Nick.
Zeeshan Rang
I 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
(My itemrenderer is in a seperate MXML file in Flash Builder 4)
Magnus Smith
A: 

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>
Gabriel McAdams
+1  A: 

Make sure what you are trying to reference is set to a public function or variable.

pfunc