View Full Version : [AS3] Capturing events in the datagrid

01-06-2009, 04:00 PM
Hi there,

New to the forums, somewhat new to AS3.0 as well, although I'm fairly handy with JavaScript and I get the fundamentals.

My problem is I am working with a Datagrid component and I want to capture a click on one of the list items in the grid so I can load a movieclip somewhere else.

I can't seem to figure out the proper event. It seems that the datagrid would handle a ListEvent.ITEM_CLICK event since it is also seemingly a list, but that didn't work. I'm a bit confused by the class reference as to what I should use. Here is my current code:

import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;

var egmXML:XML = <team>
<egm theme="Palace of Riches" assetcode="126548" state="idle" multi="no" commstatus="online" cabstatus="enabled" />
<egm theme="Powerball" assetcode="51248752" state="idle" multi="no" commstatus="online" cabstatus="enabled" />
<egm theme="Zeus" assetcode="65823541" state="idle" multi="no" commstatus="online" cabstatus="enabled" />

var themeCol:DataGridColumn = new DataGridColumn("theme");
themeCol.headerText = "Theme";
themeCol.width = 200;

(snip - etc. build all columns)

var myDP:DataProvider = new DataProvider(egmXML);

egmlisting_dg.columns = [themeCol, assetCol, stateCol, multiCol, commCol, cabCol];
egmlisting_dg.width = 800;
egmlisting_dg.dataProvider = myDP;
egmlisting_dg.rowCount = egmlisting_dg.length;

// trying to capture click on datagrid row here

egmlisting_dg.addEventListener(ListEvent.ITEM_CLIC K, handleClick);

function handleClick (ev:ListEvent) {

This does not work, I get:

1046: Type was not found or was not a compile-time constant: ListEvent.

I get the same thing even when I try DataGridEvent.ITEM_FOCUS_IN.

Can someone provide some direction?

01-06-2009, 04:08 PM
Ugh, let me just answer my own stupid question. I failed to import the ListEvent

import fl.events.ListEvent;

Now it works.

01-06-2009, 04:10 PM
Try importing event classes

import fl.events.*

01-06-2009, 04:13 PM
And that will give me them all - that's an even better idea. Thanks.