Search code examples
apache-flexflex4flexbuilderflex4.5

Flex mobile - How do I move to the next data in List.selectedItem when moving to next page?


When I move page01 to page02, I pass the same data along with it using the following code:

navigator.pushView(Page02, data);

How do I move to page02 with passing the next row of data (instead of the same data)? In other word, how to increment to the next row of data with pushView?

Thanks.


Solution

  • If you have access to the List component which displays the data you want to pass into views, you can do something like this:

    myList.dataProvider[myList.selectedIndex+1] 
    

    You'll want to do some checking to make sure that you're trying to reference an index that actually exists:

    var mySelectedObject :Object;
    if(myList.selectedIndex+1 < myList.dataProvider.length){
        mySelectedObject = myList.dataProvider[myList.selectedIndex+1] 
    } else {
        // do some other behaviour; such as selecting the first one in the list
        mySelectedObject = myList.dataProvider[0] 
    }
    navigator.pushView(page02, mySelectedObject );