Found the solution myself. I needed to extend GridRow and set the data
there.



On 6 feb, 10:12, gummybears <[email protected]> wrote:
> Hi
>
> In my AS code I am building a grid. Each grid row gets 3 event
> listeners, 1st for a mouse double click event,
> 2nd for a mouse over and the 3rd for a mouse out event like listed
> below.
> In the event handlers I want to dereference the params object but I am
> always
> getting the same values i.e the last assigned value.
>
> I understand the difference between passing params by value and by
> reference, but I am creating a new
> params object for each gridrow, so this is something I don't
> understand.
> Hope someone can help.
>
> TIA
>
> public function build_grid() : VBox {
> var params : Object;
> ......
> agrid = new Grid;
> for ( i = 0; i < records.length; i++){
>         agridrow = new GridRow;
>         agridrow.doubleClickEnabled = true;
>         agridrow.buttonMode = true;
>         agridrow.useHandCursor = true;
>
>         params = new Object;
>         params.row = i;
>         params.rin = rapport_records[i].rin;
>         agridrow.addEventListener(MouseEvent.DOUBLE_CLICK, function
> (event : MouseEvent) : void {
>                         griddoubleclick(event,params);
>                 },false,0,false
>         );
>         agridrow.addEventListener(MouseEvent.MOUSE_OVER,function
> (event : MouseEvent) : void {
>                         addrollover(event,params);
>                 },false,0,false
>         );
>         agridrow.addEventListener(MouseEvent.MOUSE_OUT,function
> (event : MouseEvent) : void {
>                         removerollover(event,params);
>                 },false,0,false
>         );
>
>        // creating grid items
>       ... more lines of code, not shown
>       // add grid items to grid row
>      ... more lines of code, not shown
>      // add grid row to grid
>     agrid.addChild(agridrow);
>
>  }
>  // more code to add grid to a vbox
>     return(vbox);
>
> }
>
> public function griddoubleclick(event : Event, params : Object) : void
> {
>         Alert.show('clicked ' + params.rin);
>
> }
>
> public function addrollover(event : Event,params : Object) : void {
>         var element : DisplayObject;
>         var gridrow : GridRow;
>     element = event.currentTarget as DisplayObject;
>         if (element is GridRow){
>                 gridrow = GridRow(element);
>                 gridrow.styleName = "rollover";
>         }
>
> }
>
> public function removerollover(event : Event,params : Object) : void {
>         var element : DisplayObject;
>         var gridrow : GridRow;
>     element = event.currentTarget as DisplayObject;
>
>         if (element is GridRow){
>                 gridrow = GridRow(element);
>
>         if ( (params.row % 2) == 0){
>             gridrow.styleName = "even";
>         } else {
>             gridrow.styleName = "odd";
>         }
>         }
>
> }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to