Pergunta

I've run into some problem trying to get the index of a row currently being hovered opon on a datagrid component of flash using ActionScript 3.0.

So please how can I get the row index of a datagrid on mouse rollover in AS3.

Thanks

Foi útil?

Solução

You use the ListEvent.ITEM_ROLL_OVER event rather than a basic mouse over

import fl.events.ListEvent;

var sampleItem1:Object = { Name:"John Alpha",   Number:"555-123-0101", Email:"jalpha@fictitious.com" };
var sampleItem2:Object = { Name:"Mary Bravo",   Number:"555-372-3322", Email:"mbravo@fictitious.com" };
var sampleItem3:Object = { Name:"Trevor Gamma", Number:"555-485-1212", Email:"tgamma@fictitious.com" };
var sampleItem4:Object = { Name:"Susan Delta",  Number:"555-987-3434", Email:"sdelta@fictitious.com" };     

dg.columns = ["Name","Number","Email"];
dg.addItem(sampleItem1);
dg.addItem(sampleItem2);
dg.addItem(sampleItem3);
dg.addItem(sampleItem4);

function gridRollOver(e:ListEvent):void
{
    trace("rowIndex: " + e.rowIndex + " columnIndex: " + e.columnIndex);    
}
dg.addEventListener(ListEvent.ITEM_ROLL_OVER, gridRollOver);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top