Actionscript 3 如何在循环中提示用户而不继续执行代码(通过弹出窗口)

Actionscript 3 如何在循环中提示用户而不继续执行代码(通过弹出窗口),actionscript-3,flex4,flashbuilder4,Actionscript 3,Flex4,Flashbuilder4,我有一个datagrid,其中填充了对象(表示.pdf),这些对象都共享一个“索引”属性(在SQL表中索引)。如果对它们进行了索引,则选中它们各自的复选框并将“索引”设置为true。我的窗口中还有一个按钮,单击该按钮时,将调用所选对象以编制索引 问题是,如果一些已经被索引,我应该提示用户决定做什么。忽略(不做任何事情)或替换(在表中删除并重新索引)。这是我尝试过的,但它所做的只是堆叠窗口并继续索引它们 private function indexPDFData(evt:MouseEvent):v

我有一个datagrid,其中填充了对象(表示.pdf),这些对象都共享一个“索引”属性(在SQL表中索引)。如果对它们进行了索引,则选中它们各自的复选框并将“索引”设置为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的新手,因此任何帮助或见解都将不胜感激

private-var-currentIndex:int//用于记住索引为true的项的索引
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;
}
私有函数indexPDFData(evt:MouseEvent):void//按钮处理程序 { 如果(pdfScreen.grid2.selectedIndices.length>0)// { 检查项目(0); } 其他的 { 显示(“必须选择要索引的问题!”,“索引PDF”); } } 私有函数检查项(startIndex:int):无效{ 对于(变量i:int=startIndex;i

关闭窗口(自定义弹出窗口)时,请记住调用checkItems(currentIndex+1)

太棒了!它几乎起作用了,除了在调用break时,它会立即进入索引(即使有弹出窗口)。但它将我引向了正确的方向,并且它是有效的:D.我在循环之前添加了一个if语句,以检查currentIndex是否位于末尾。如果是,则开始索引过程。我真的很感激!应以返回代替中断。:)