Search code examples
apache-flexdatagriddataprovider

Flex Loop through DataGrid, get object and index


I have a DataGrid that represents layers - each row is an image on the stage. Now I would like that dragging a layer, will change the childIndex of that image on the stage.

In order to do that I need to loop through the DataGrid rows after the drag, get the image from the dataprovider for each row and change the childIndex of that image to the index of the row.

I can't figure out how to loop through the rows, get the row index and the image that is repressed by the row.

Please help :)


Solution

  • I have found the solution:

    private function layers_list_dragCompleteHandler(event:DragEvent):void
            {
                var idx:int = layers_list_box.calculateDropIndex(event);
                for (var i:int = 0; i < layers.length; i++)
                {
                    var stageObject:StageObject = (layers.getItemAt(i) as AniBaniClip).GetFirstStageObject(0);
                    AniBani.getEditor().editor_stage.setElementIndex(stageObject, i + 2);
                }
            }