0

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 :)

Light
  • 1,647
  • 3
  • 22
  • 39
  • 3
    Don't loop through the rows; use the dataProvider. `dg.dataProvider.getItemIndex(item)` – RIAstar Jun 14 '12 at 13:14
  • @Light, you update the index in datagrid, the childindex of the image will not update automatically. They are two different things. Tell us your flow. Your problem may not be in the looping. According to your question, RIAstar's comment can help you. – michael Jun 14 '12 at 16:38
  • I can loop through the dataprovider, however, when I change the rows order in the datagrid, will it reflect in the dataprovider? This is the problem... – Light Jun 18 '12 at 14:19
  • Please add some code.... – Mahesh Parate Jun 19 '12 at 09:11
  • I have found the solution, actually it is very easy, because the dataprovider is bind to the datagrid, dragging the rows is changing the dataprovider as well. – Light Jun 19 '12 at 14:36

1 Answers1

0

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);
            }
        }
Light
  • 1,647
  • 3
  • 22
  • 39