0

我有一个填充了对象(代表.pdf)的数据网格,它们都共享一个“索引”属性(在 SQL 表中索引)。如果它们被编入索引,则它们各自的复选框被选中并将 indexed 设置为 true。我的窗口中还有一个按钮,单击该按钮时,将调用所选对象进行索引。

问题是如果一些已经被索引,我应该提示用户决定做什么。忽略(不做任何事情)或替换(在表中删除并重新索引)。这是我尝试过的,但它所做的只是堆叠窗口并继续对它们进行索引。

private function indexPDFData(evt:MouseEvent):void  //button handler
    {
        var i:int=0;

        if(pdfScreen.grid2.selectedIndices.length>0) //if items are selected
        {
                for each(var item:Object in pdfScreen.grid2.selectedItems)
                {
                    if(item.indexed=="true")
                    {
                        var window:CustomPopUp = PopUpManager.createPopUp(pdfScreen, CustomPopUp, true) as CustomPopUp;
                        window.ignoreBtn.addEventListener(MouseEvent.CLICK, ignore);
                        window.replaceBtn.addEventListener(MouseEvent.CLICK, replace);
                    }
                }

            sendNotification(ApplicationFacade.COMMAND_INDEX_PDFS, (pdfScreen.grid2.selectedItems));
            pdfScreen.controlBtns.enabled=false;
        }
        else
        {   
            Alert.show("Must select an issue to index!", "Index PDFs");     
        }
    }

想要的是循环在用户做出选择时停止,并在他单击弹出窗口中的两个选项后继续。我尝试了很多方法,但没有一个有效。我对 as3 很陌生,所以任何帮助或见解都将不胜感激!

4

1 回答 1

0
private var currentIndex:int;//used to remember the index of the item whose indexed is true

private function indexPDFData(evt:MouseEvent):void  //button handler
{
    if(pdfScreen.grid2.selectedIndices.length>0) //
    {
         checkItems(0);
    }
    else
    {
         Alert.show("Must select an issue to index!", "Index PDFs");     
    }

}

private function checkItems(startIndex:int):void {

     for (var i:int = startIndex; i < pdfScreen.grid2.selectedItems.length; i++)
     {
          var item:Object = pdfScreen.grid2.selectedItems[i];

          if(item.indexed=="true")
          {
               var window:CustomPopUp = PopUpManager.createPopUp(pdfScreen, CustomPopUp, true) as CustomPopUp;
               window.ignoreBtn.addEventListener(MouseEvent.CLICK, ignore);
               window.replaceBtn.addEventListener(MouseEvent.CLICK, replace);
               currentIndex = i;//call checkItems(currentIndex + 1) when close window
               break;
          }
     }

    sendNotification(ApplicationFacade.COMMAND_INDEX_PDFS, (pdfScreen.grid2.selectedItems));
    pdfScreen.controlBtns.enabled=false;
}

当你关闭 window(Your CustomPopUp) 时,记得调用 checkItems(currentIndex + 1);

于 2013-06-19T16:32:39.790 回答