The inline component appears to be treated as a completely separate
entity in my tests. IT cannot call functions within it's parent.
First add an event into the in-line component and make sure that it
bubbles. The second Boolean value sets the event to bubble. Bubbble
just means that if the event is not handled, it is broadcast up to
it's parent's parent until it is handled.
<mx:Component>
<mx:Metadata>
[Event(name="Delete", type="flash.events.Event")]
</mx:Metadata>
<mx:VBox horizontalAlign="center">
<mx:Button label="" icon="@Embed('../images/delete.png')"
click="dispatchEvent(new Event('Edit',true));" />
</mx:VBox>
</mx:Component>
Because of the nature of buttons inside a data grid, the 'delete'
event will not be explicitly available on the datagrid. But, you can
manually create a listener for it. I do that in an CreationComplete
method, like this:
public function onCreationComplete():void{
DG.addEventListener('Delete', deleteRow);
}
wher e"DG" is the id of your datagrid. put the deleteRow function
in your parent component just like normal.
At 01:48 AM 3/13/2007, you wrote:
>Inside of an mxml file, I have a datagrid, with a Button item
>renderer as such:
>
>
><mx:DataGridColumn headerText="delete" textAlign="center" editable="false">
><mx:itemRenderer>
><mx:Component>
><mx:VBox horizontalAlign="center">
><mx:Button label="" icon="@Embed('../images/delete.png')" />
></mx:VBox>
></mx:Component>
></mx:itemRenderer>
></mx:DataGridColumn>
>
>
>In that Button, I would like to call a function that exists in the
>same .mxml file
>
>
>public function deleteRow( data:XML ):void{
>
>
>}
>
>
>
>Unfortunately, if I edit the button to read like:
>
><mx:Button label="" icon="@Embed('../images/delete.png')"
>click="deleteRow( data );" />
>
>It writes that the function deleteRow doesn't exist, which I imagine
>is a scope problem. How do I get around this?
>
>Thanks in advance,
>Alex
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Macromedia ColdFusion MX7
Upgrade to MX7 & experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion
Archive: http://www.houseoffusion.com/groups/Flex/message.cfm/messageid:3726
Subscription: http://www.houseoffusion.com/groups/Flex/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.37