That's right but I wondered if there was another way.
Meanwhile I found something that works as well.
Using the itemrenderer allows to send the current data item back to
the calling container.

private function dispatchRowClickEvent(ev:ListEvent):void{
    var e:ListEvent=new ListEvent('rowClick');
    e.rowIndex=ev.rowIndex;
    e.itemRenderer = ev.itemRenderer; // that does the trick
    dispatchEvent(e);
}

Romain.


--- In [email protected], "Roman Protsiuk"
<[EMAIL PROTECTED]> wrote:
>
> Why don't you use custom events? I use standard events in my
components only
> in situations like "something is changed" - we notify about it using
> Event.CHANGE. But in most custom components custom events used
(especially
> if some event specific information is sent along with it).
> 
> R.
> 
> On 6/5/07, Romain <[EMAIL PROTECTED]> wrote:
> >
> >   Hi,
> >
> > I am making a custom mxml component, composed of a datagrid and a few
> > buttons.
> > I am potentially dispatching the following 2 events:
> > [Event(name="btnClick", type="flash.events.MouseEvent")]
> > [Event(name="rowClick", type="mx.events.ListEvent")]
> >
> > These events are thrown by event handlers on the actual individual
> > component (either a button or a grid).
> > for the grid:
> > private function dispatchRowClickEvent(ev:ListEvent):void{
> > var e:ListEvent=new ListEvent('rowClick');
> > e.rowIndex=ev.rowIndex;
> > dispatchEvent(e);
> > }
> > for the button
> > <mx:Button id="btnRefreshRecord"
> > icon="@Embed(source='../assets/icons/table_refresh.png')" width="20"
> > height="20" click="dispatchEvent(new Event('gridRefresh'))"
> > toolTip="Refresh table content" />
> >
> > My problem is when I consume these events from the component, I'd like
> > to be able to write something like:
> > public function dgDoubleClickHandler(event:ListEvent) : void
> > {
> > var currentIssueForm:IssueForm = new IssueForm();
> > var buf:XML = XML(event.currentTarget.selectedItem);
> > currentIssueForm.modelIssue = buf;
> > PopUpManager.addPopUp(currentIssueForm, this, true);
> > PopUpManager.centerPopUp(currentIssueForm);
> > }
> >
> > However at runtime it fails because event.currentTarget.selectedItem
> > is null.
> > It is null because the event I am catching is the custom component
> > event and not the low-level datagrid event....
> >
> > Is there a way to wrap the datagrid event [and keep its content]
> > whilst still renaming it ?
> > Or maybe there is just a simpler way to do this ?
> >
> > Thanks,
> >
> > Romain.
> >
> >  
> >
>


Reply via email to