2016-06-10 4 views
0

이것은 매우 이상한 또 다른 문제입니다. 플레이어가 버튼 중 하나를 선택하면 사라지는 것으로 간주되는 재생 흐름의 대화입니다. 내가 뭘하려고해도 사라지는거야.removeChild 후 AS3 대화 상자가 남아있어 사라지게하려는 노력이 더 많습니다.

특히 이상한 점은 호출 지점을 포함하여 적어도 18 개월 동안 변경된 코드가 하나도 없으며 며칠 전에 우주선 객체와 관련이있는 커밋이 정상적으로 작동한다는 것입니다. , 대화 상자가 아닙니다.

그리고이 대화 상자가 호출되는 곳은 단 하나뿐입니다. 내가 처음에는 궁금해했던 것 중 하나는이 대화 상자의 여러 인스턴스가 어떻게 든 만들어 졌는지 아닌지 아닌지입니다.

Player has selected one of his ships and clicked on a valid enemy target, all combat calculations done and Broadside Confirm dialog instanced, all we need to know is whether player wants to shoot at rigging or the hull.

화재 버튼 중 하나에 플레이어를 클릭 우리가 전투의 결과를 계산하고 현측 결과 화면에서뿐만 아니라 적 선박의 정보 화면에 모두 표시

. 플레이어가 취소하면 화면을 비우게됩니다.

측면 결과 대화 상자에는 측면 닫기 확인 대화 상자 취소 버튼과 동일한 기능을 호출하여 화면을 지우는 닫기 버튼이 있습니다.

여기 Broadside Results Dialog보기에서 플레이어가 화재 버튼 중 하나를 눌렀을 때 데미지가 계산되고 적용되었습니다. 이 시점에서 Broadside Confirm 대화 상자는 이미 없어졌지만, 결과 대화 상자 아래에 숨어 있지는 않습니다.

Broadside Results Phase

여기 몇 일 전까지 만해도 괜찮 았는데 그 "명확한지도"코드의 첫 번째 버전입니다 :

//clears game map of dialogs and resets ships to deselected states, called from several places 
     function clearGameMap(eventTarget:Object) { 

      //clear selected state on all ships, remove ship info screen, broadside confirm and broadside results dialogs 
      for (var i: int = 0; i < shipListSide1.length; i++) { 

       //clear all selected states and return to default unselected background graphic 
       shipListSide1[i].selected = false; 
       shipListSide1[i].combatSelected = false; 

       //selection borders 
       var borderChild = shipListSide1[i].getChildByName("shipBorder"); 
       borderChild.visible = false; 

       var borderChildCombat = shipListSide1[i].getChildByName("borderCombat"); 
       borderChildCombat.visible = false; 

       //show default counter background, build label name, leave surrendered ships to sleep peacefully 
       if (!shipListSide1[i].isSurrendered) { 

        shipListSide1[i].gotoAndStop(shipListSide1[i].country+"_def"); 
       } 
      } 

      //clear selected states side2 
      for (var i: int = 0; i < shipListSide2.length; i++) { 

       //clear all selected states and return to default unselected background graphic 
       shipListSide2[i].selected = false; 
       shipListSide2[i].combatSelected = false; 

       //selection borders 
       var borderChild = shipListSide2[i].getChildByName("shipBorder"); 
       borderChild.visible = false; 

       var borderChildCombat2 = shipListSide2[i].getChildByName("borderCombat"); 
       borderChildCombat2.visible = false; 

       //show default counter background, build label name, leave surrendered ships to sleep peacefully 
       if (!shipListSide2[i].isSurrendered) { 

        shipListSide2[i].gotoAndStop(shipListSide2[i].country+"_def"); 
       } 

      } 

      //in this one case we're transitioning from broadside confirm dialog to broadside results dialog and we DON'T want to remove the info screens 
      if (("broadsideFireButtonHull" != eventTarget.name) && ("broadsideFireButtonRigging" != eventTarget.name)) { 

       //remove ship info screen 
       if (currShipInfo.parent) { 

        removeChild(currShipInfo); 
       } 
       //remove ship target info screen 
       if (currShipInfo_combat.parent) { 

        removeChild(currShipInfo_combat); 
       } 
      } 

      //remove broadside confirm dialog 
      if (broadsideConfirmDialog.parent) { 

       removeChild(broadsideConfirmDialog); 

      } 
      //remove broadside results dialog 
      if (broadsideResultsDialog.parent) { 

       removeChild(broadsideResultsDialog); 
      } 
     } 

가 작동을 중지하지만, 이것은 내가 지금 무엇을 얻을 :

Everything is cleared except the Broadside Confirm Dialog, which already should have disappeared when we went to Broadside Results. Ship names are gone but all other children still present and event listeners on buttons still functional

그 시점에서 변수를 확인하고 부모가 이제 null이지만 실제로 표시됩니다. 화면에. 아니면 적어도 다른 인스턴스가 보이지 않습니다.

그래서 내가 멀리 갈 수 있도록 몇 가지 노력을했다 :

   //remove broadside confirm dialog 
      if (broadsideConfirmDialog.parent) { 

       broadsideConfirmDialog.parent.setChildIndex(broadsideConfirmDialog, broadsideConfirmDialog.parent.getChildIndex(broadsideConfirmDialog) - 1); 
       broadsideConfirmDialog.visible = false; 
       broadsideConfirmDialog.alpha = 0; 

       var fireHullButton = broadsideConfirmDialog.getChildByName("broadsideFireButtonHull"); 
       var fireRiggingButton = broadsideConfirmDialog.getChildByName("broadsideFireButtonRigging"); 
       var broadside_CancelButton = broadsideConfirmDialog.getChildByName("broadsideCancelButton"); 

       fireHullButton.removeEventListener(MouseEvent.CLICK, fireButtonHandler); 
       fireHullButton.removeEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
       fireHullButton.removeEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

       fireRiggingButton.removeEventListener(MouseEvent.CLICK, fireButtonHandler); 
       fireRiggingButton.removeEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
       fireRiggingButton.removeEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

       broadside_CancelButton.removeEventListener(MouseEvent.CLICK, cancelButtonHandler); 
       broadside_CancelButton.removeEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
       broadside_CancelButton.removeEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

       removeChild(broadsideConfirmDialog); 

      } 

제거 이벤트 리스너를, Z 순서, 눈에 보이지 않는, 알파 0에 다시 밀어 시도했지만 작동 중 누구도, 그것은 터미네이터 없다 대화. 그러나이 코드는 모두 오류없이 실행됩니다. 다시 한 번 다른 인스턴스가 표시되지 않고 두 번째 인스턴스가 어떻게 존재하는지도 알 수 없지만 필요한 이벤트 리스너를 성공적으로 제거한 후에도 해당 롤오버는 롤오버를 계속 수행합니다.

다음은 여러 달에 걸쳐 변경되지 않은 Broadside Confirm 및 Broadside Results 대화 상자와 이벤트 리스너/처리기를 만드는 코드입니다. 분명히 내 평판은 내가 더 많은 스크린 샷을 추가 할 수있는 지금 충분하다

function createBroadsideConfirmDialog(firingShip, targetShip, initialHitTable, hitTable, modSternRake, modRakeValue, modCrewQuality, modInitialBroadside, modShotType, modAnchored, modCrewLosses, finalGuns, targetRange) { 

      //only display if ship can fire to this side 
      if ((targetObj.targetStarboard && targetObj.firingShip.loadedRight) || (false == targetObj.targetStarboard && targetObj.firingShip.loadedLeft)) { 

       broadsideConfirmDialog = new Broadside_Confirm_Dialog(); 

       broadsideConfirmDialog.x = 430; 
       broadsideConfirmDialog.y = 117; 

       addChild(broadsideConfirmDialog); 

       //firing and target ship name fields 
       var broadsideShipNameFont = new ShipNameFont(); 

       var textBroadsideShipNameFormat: TextFormat = new TextFormat(); 
       textBroadsideShipNameFormat.size = 16; 
       textBroadsideShipNameFormat.font = broadsideShipNameFont.fontName; 

       textBroadsideShipNameFire.defaultTextFormat = textBroadsideShipNameFormat; 

       textBroadsideShipNameFire.width = 200; 
       textBroadsideShipNameFire.height = 16; 
       textBroadsideShipNameFire.x = 55; 
       textBroadsideShipNameFire.y = 15; 
       textBroadsideShipNameFire.embedFonts = true; 
       textBroadsideShipNameFire.textColor = 0xFFFFFF; 
       textBroadsideShipNameFire.htmlText = "<p align='center'>" + firingShip.name + "</p>"; 

       broadsideConfirmDialog.addChild(textBroadsideShipNameFire); 

       textBroadsideShipNameTarget.defaultTextFormat = textBroadsideShipNameFormat; 

       textBroadsideShipNameTarget.width = 200; 
       textBroadsideShipNameTarget.height = 16; 
       textBroadsideShipNameTarget.x = 55; 
       textBroadsideShipNameTarget.y = 71; 
       textBroadsideShipNameTarget.embedFonts = true; 
       textBroadsideShipNameTarget.textColor = 0xFFFFFF; 
       textBroadsideShipNameTarget.htmlText = "<p align='center'>" + targetShip.name + "</p>"; 

       broadsideConfirmDialog.addChild(textBroadsideShipNameTarget); 

       //gun and range fields 
       var broadsideConfirmFields = new Arial(); 

       var textBroadsideGunsFormat: TextFormat = new TextFormat(); 
       textBroadsideGunsFormat.size = 16; 
       textBroadsideGunsFormat.font = broadsideConfirmFields.fontName; 

       var textBroadsideGuns: TextField = new TextField(); 
       textBroadsideGuns.defaultTextFormat = textBroadsideGunsFormat; 

       textBroadsideGuns.width = 80; 
       textBroadsideGuns.height = 30; 
       textBroadsideGuns.x = 167; 
       textBroadsideGuns.y = 186; 
       textBroadsideGuns.embedFonts = true; 
       textBroadsideGuns.textColor = 0xFFCC00; 

       textBroadsideGuns.htmlText = "<p align='left'>" + finalGuns + "</p>"; 

       broadsideConfirmDialog.addChild(textBroadsideGuns); 

       var textBroadsideRange: TextField = new TextField(); 
       textBroadsideRange.defaultTextFormat = textBroadsideGunsFormat; 

       textBroadsideRange.width = 80; 
       textBroadsideRange.height = 30; 
       textBroadsideRange.x = 67; 
       textBroadsideRange.y = 186; 
       textBroadsideRange.embedFonts = true; 
       textBroadsideRange.textColor = 0xFFCC00; 

       textBroadsideRange.htmlText = "<p align='left'>" + targetRange + "</p>"; 

       broadsideConfirmDialog.addChild(textBroadsideRange); 

       //initial and final hit table fields 
       textBroadsideHitTableFormat.size = 22; 
       textBroadsideHitTableFormat.font = broadsideConfirmFields.fontName; 

       var textBroadsideHitTable: TextField = new TextField(); 
       textBroadsideHitTable.defaultTextFormat = textBroadsideHitTableFormat; 

       textBroadsideHitTable.width = 80; 
       textBroadsideHitTable.height = 30; 
       textBroadsideHitTable.x = 235; 
       textBroadsideHitTable.y = 185; 
       textBroadsideHitTable.embedFonts = true; 
       textBroadsideHitTable.textColor = 0xFFCC00; 

       textBroadsideHitTable.htmlText = "<p align='left'>" + initialHitTable + "</p>"; 

       broadsideConfirmDialog.addChild(textBroadsideHitTable); 

       var textBroadsideFinalHitTable: TextField = new TextField(); 
       textBroadsideFinalHitTable.defaultTextFormat = textBroadsideHitTableFormat; 

       textBroadsideFinalHitTable.name = "textBroadsideFinalHitTable"; 
       textBroadsideFinalHitTable.width = 80; 
       textBroadsideFinalHitTable.height = 30; 
       textBroadsideFinalHitTable.x = 235; 
       textBroadsideFinalHitTable.y = 325; 
       textBroadsideFinalHitTable.embedFonts = true; 
       textBroadsideFinalHitTable.textColor = 0xFFCC00; 

       textBroadsideFinalHitTable.htmlText = "<p align='left'>" + hitTable + "</p>"; 

       broadsideConfirmDialog.addChild(textBroadsideFinalHitTable); 

       //modifier fields 
       var textBroadsideModifiersFormat: TextFormat = new TextFormat(); 
       textBroadsideModifiersFormat.size = 13; 
       textBroadsideModifiersFormat.font = broadsideConfirmFields.fontName; 

       var textBroadsideModCrew: TextField = new TextField(); 
       textBroadsideModCrew.defaultTextFormat = textBroadsideModifiersFormat; 

       textBroadsideModCrew.width = 80; 
       textBroadsideModCrew.height = 30; 
       textBroadsideModCrew.x = 232; 
       textBroadsideModCrew.y = 214; 
       textBroadsideModCrew.embedFonts = true; 
       textBroadsideModCrew.textColor = 0xFFDD8C; 

       textBroadsideModCrew.htmlText = "<p align='left'>" + modCrewQuality + "</p>"; 

       if ("0" == modCrewQuality) { 
        textBroadsideModCrew.htmlText = "<p align='left'>--</p>"; 
        textBroadsideModCrew.x = 238; 
        textBroadsideModCrew.textColor = 0x999999; 
       } 

       broadsideConfirmDialog.addChild(textBroadsideModCrew); 

       var textBroadsideModAmmo: TextField = new TextField(); 
       textBroadsideModAmmo.defaultTextFormat = textBroadsideModifiersFormat; 

       textBroadsideModAmmo.width = 80; 
       textBroadsideModAmmo.height = 30; 
       textBroadsideModAmmo.x = 232; 
       textBroadsideModAmmo.y = 233; 
       textBroadsideModAmmo.embedFonts = true; 
       textBroadsideModAmmo.textColor = 0xFFDD8C; 

       textBroadsideModAmmo.htmlText = "<p align='left'>" + modShotType + "</p>"; 

       if ("0" == modShotType) { 
        textBroadsideModAmmo.htmlText = "<p align='left'>--</p>"; 
        textBroadsideModAmmo.x = 238; 
        textBroadsideModAmmo.textColor = 0x999999; 
       } 

       broadsideConfirmDialog.addChild(textBroadsideModAmmo); 

       var textBroadsideModRake: TextField = new TextField(); 
       textBroadsideModRake.defaultTextFormat = textBroadsideModifiersFormat; 

       textBroadsideModRake.width = 80; 
       textBroadsideModRake.height = 30; 
       textBroadsideModRake.x = 232; 
       textBroadsideModRake.y = 251; 
       textBroadsideModRake.embedFonts = true; 
       textBroadsideModRake.textColor = 0xFFDD8C; 

       textBroadsideModRake.htmlText = "<p align='left'>" + modRakeValue + "</p>"; 

       if ("0" == modRakeValue) { 
        textBroadsideModRake.htmlText = "<p align='left'>--</p>"; 
        textBroadsideModRake.x = 238; 
        textBroadsideModRake.y = 249; 
        textBroadsideModRake.textColor = 0x999999; 
       } 

       broadsideConfirmDialog.addChild(textBroadsideModRake); 

       var textBroadsideModSternRake: TextField = new TextField(); 
       textBroadsideModSternRake.defaultTextFormat = textBroadsideModifiersFormat; 

       textBroadsideModSternRake.width = 80; 
       textBroadsideModSternRake.height = 30; 
       textBroadsideModSternRake.x = 232; 
       textBroadsideModSternRake.y = 269; 
       textBroadsideModSternRake.embedFonts = true; 
       textBroadsideModSternRake.textColor = 0xFFDD8C; 

       textBroadsideModSternRake.htmlText = "<p align='left'>" + modSternRake + "</p>"; 

       if ("0" == modSternRake) { 
        textBroadsideModSternRake.htmlText = "<p align='left'>--</p>"; 
        textBroadsideModSternRake.x = 238; 
        textBroadsideModSternRake.y = 267; 
        textBroadsideModSternRake.textColor = 0x999999; 
       } 

       broadsideConfirmDialog.addChild(textBroadsideModSternRake); 

       var textBroadsideModInitBroad: TextField = new TextField(); 
       textBroadsideModInitBroad.defaultTextFormat = textBroadsideModifiersFormat; 

       textBroadsideModInitBroad.width = 80; 
       textBroadsideModInitBroad.height = 30; 
       textBroadsideModInitBroad.x = 232; 
       textBroadsideModInitBroad.y = 287; 
       textBroadsideModInitBroad.embedFonts = true; 
       textBroadsideModInitBroad.textColor = 0xFFDD8C; 

       textBroadsideModInitBroad.htmlText = "<p align='left'>" + modInitialBroadside + "</p>"; 

       if ("0" == modInitialBroadside) { 
        textBroadsideModInitBroad.htmlText = "<p align='left'>--</p>"; 
        textBroadsideModInitBroad.x = 238; 
        textBroadsideModInitBroad.y = 285; 
        textBroadsideModInitBroad.textColor = 0x999999; 
       } 

       broadsideConfirmDialog.addChild(textBroadsideModInitBroad); 

       var textBroadsideModCrewLosses: TextField = new TextField(); 
       textBroadsideModCrewLosses.defaultTextFormat = textBroadsideModifiersFormat; 

       textBroadsideModCrewLosses.width = 80; 
       textBroadsideModCrewLosses.height = 30; 
       textBroadsideModCrewLosses.x = 234; 
       textBroadsideModCrewLosses.y = 304; 
       textBroadsideModCrewLosses.embedFonts = true; 
       textBroadsideModCrewLosses.textColor = 0xFFDD8C; 

       textBroadsideModCrewLosses.htmlText = "<p align='left'>" + modCrewLosses + "</p>"; 

       if ("0" == modCrewLosses) { 
        textBroadsideModCrewLosses.htmlText = "<p align='left'>--</p>"; 
        textBroadsideModCrewLosses.x = 238; 
        textBroadsideModCrewLosses.y = 303; 
        textBroadsideModCrewLosses.textColor = 0x999999; 
       } 

       broadsideConfirmDialog.addChild(textBroadsideModCrewLosses); 

       //fire and cancel buttons 
       var broadsideFireButtonHull: Broadside_Confirm_Btn_Fire_Hull = new Broadside_Confirm_Btn_Fire_Hull(); 
       broadsideFireButtonHull.gotoAndStop('default'); 

       broadsideFireButtonHull.x = 208; 
       broadsideFireButtonHull.y = 372; 

       broadsideFireButtonHull.name = "broadsideFireButtonHull"; 
       broadsideFireButtonHull.buttonMode = true; 
       broadsideFireButtonHull.useHandCursor = true; 
       broadsideFireButtonHull.addEventListener(MouseEvent.CLICK, fireButtonHandler); 
       broadsideFireButtonHull.addEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
       broadsideFireButtonHull.addEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

       broadsideConfirmDialog.addChild(broadsideFireButtonHull); 

       var broadsideFireButtonRigging: Broadside_Confirm_Btn_Fire_Rigging = new Broadside_Confirm_Btn_Fire_Rigging(); 
       broadsideFireButtonRigging.gotoAndStop('default'); 

       broadsideFireButtonRigging.x = 99; 
       broadsideFireButtonRigging.y = 372; 

       broadsideFireButtonRigging.name = "broadsideFireButtonRigging"; 
       broadsideFireButtonRigging.buttonMode = true; 
       broadsideFireButtonRigging.useHandCursor = true; 
       broadsideFireButtonRigging.addEventListener(MouseEvent.CLICK, fireButtonHandler); 
       broadsideFireButtonRigging.addEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
       broadsideFireButtonRigging.addEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

       broadsideConfirmDialog.addChild(broadsideFireButtonRigging); 

       var broadsideCancelButton: Broadside_Confirm_Btn_Cancel = new Broadside_Confirm_Btn_Cancel(); 
       broadsideCancelButton.gotoAndStop('default'); 

       broadsideCancelButton.x = 12; 
       broadsideCancelButton.y = 372; 

       broadsideCancelButton.name = "broadsideCancelButton"; 
       broadsideCancelButton.buttonMode = true; 
       broadsideCancelButton.useHandCursor = true; 
       broadsideCancelButton.addEventListener(MouseEvent.CLICK, cancelButtonHandler); 
       broadsideCancelButton.addEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
       broadsideCancelButton.addEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

       broadsideConfirmDialog.addChild(broadsideCancelButton); 
      } 
     } 

     function createBroadsideResultsDialog() { 

      //left offset for damage squares 
      const BROADSIDE_RESULTS_LEFT_OFFSET = 150; 
      const INFO_SQUARE_SIZE = 13; 

      ////remove the broadside confirm dialog 
      //if (broadsideConfirmDialog.parent) { 

      // broadsideConfirmDialog.parent.removeChild(broadsideConfirmDialog); 
      //} 

      //instance broadside results dialog 
      broadsideResultsDialog = new Broadside_Results_Dialog(); 

      broadsideResultsDialog.x = 430; 
      broadsideResultsDialog.y = 117; 

      addChild(broadsideResultsDialog); 

      //firing and target ship name fields 
      broadsideResultsDialog.addChild(textBroadsideShipNameFire); 
      broadsideResultsDialog.addChild(textBroadsideShipNameTarget); 

      //initial and final hit table fields 
      textBroadsideHitTableFormat.size = 28; 

      var textBroadsideResultsHitTable: TextField = new TextField(); 
      textBroadsideResultsHitTable.defaultTextFormat = textBroadsideHitTableFormat; 

      textBroadsideResultsHitTable.width = 80; 
      textBroadsideResultsHitTable.height = 30; 
      textBroadsideResultsHitTable.x = 90; 
      textBroadsideResultsHitTable.y = 192; 
      textBroadsideResultsHitTable.embedFonts = true; 
      textBroadsideResultsHitTable.textColor = 0xFFCC00; 

      textBroadsideResultsHitTable.htmlText = "<p align='left'>" + targetObj.hitTable + "</p>"; 

      broadsideResultsDialog.addChild(textBroadsideResultsHitTable); 

      var textBroadsideResultsDieRoll: TextField = new TextField(); 
      textBroadsideResultsDieRoll.defaultTextFormat = textBroadsideHitTableFormat; 

      textBroadsideResultsDieRoll.width = 80; 
      textBroadsideResultsDieRoll.height = 30; 
      textBroadsideResultsDieRoll.x = 192; 
      textBroadsideResultsDieRoll.y = 192; 
      textBroadsideResultsDieRoll.embedFonts = true; 
      textBroadsideResultsDieRoll.textColor = 0xFFCC00; 

      textBroadsideResultsDieRoll.htmlText = "<p align='left'>" + diceRoll + "</p>"; 

      broadsideResultsDialog.addChild(textBroadsideResultsDieRoll); 

      //add red X squares for ship's hull damage 
      for (var i: int = 0; i < damageObj.initialDamageHull; i++) { 

       var xSquareHull = new Ship_Info_SquareX(); 
       xSquareHull.x = (i * INFO_SQUARE_SIZE) + BROADSIDE_RESULTS_LEFT_OFFSET; 
       xSquareHull.y = 254; 
       broadsideResultsDialog.addChild(xSquareHull); 
      } 

      //add red X squares for ship's gun damage 
      for (var i: int = 0; i < damageObj.initialDamageGun; i++) { 

       var xSquareGun = new Ship_Info_SquareX(); 
       xSquareGun.x = (i * INFO_SQUARE_SIZE) + BROADSIDE_RESULTS_LEFT_OFFSET; 
       xSquareGun.y = 280; 
       broadsideResultsDialog.addChild(xSquareGun); 
      } 

      //add red X squares for ship's rigging damage 
      for (var i: int = 0; i < damageObj.initialDamageRigging; i++) { 

       var xSquareRigging = new Ship_Info_SquareX(); 
       xSquareRigging.x = (i * INFO_SQUARE_SIZE) + BROADSIDE_RESULTS_LEFT_OFFSET; 
       xSquareRigging.y = 306; 
       broadsideResultsDialog.addChild(xSquareRigging); 
      } 

      //add red X squares for ship's crew damage 
      for (var i: int = 0; i < damageObj.initialDamageCrew; i++) { 

       var xSquareCrew = new Ship_Info_SquareX(); 
       xSquareCrew.x = (i * INFO_SQUARE_SIZE) + BROADSIDE_RESULTS_LEFT_OFFSET; 
       xSquareCrew.y = 332; 
       broadsideResultsDialog.addChild(xSquareCrew); 
      } 

      var broadsideResultsCloseButton: WSIM_Broadside_Results_Button_Close = new WSIM_Broadside_Results_Button_Close(); 
      broadsideResultsCloseButton.gotoAndStop('default'); 

      broadsideResultsCloseButton.x = 111; 
      broadsideResultsCloseButton.y = 372; 

      broadsideResultsCloseButton.name = "broadsideResultsCloseButton"; 
      broadsideResultsCloseButton.buttonMode = true; 
      broadsideResultsCloseButton.useHandCursor = true; 
      broadsideResultsCloseButton.addEventListener(MouseEvent.CLICK, cancelButtonHandler); 
      broadsideResultsCloseButton.addEventListener(MouseEvent.ROLL_OVER, broadsideButtonRollOverHandler); 
      broadsideResultsCloseButton.addEventListener(MouseEvent.ROLL_OUT, broadsideButtonRollOutHandler); 

      broadsideResultsDialog.addChild(broadsideResultsCloseButton); 
     } 

     //broadside confirm fire button event handler, initiates calculation and application of damage to target ship 
     function fireButtonHandler(e: Event) { 

      //extra insurance we don't shoot when we shouldn't be able to 
      if ((targetObj.firingShip.loadedRight && targetObj.targetStarboard) || (targetObj.firingShip.loadedLeft && !targetObj.targetStarboard)) { 

       var broadsideSound: Sound = new Sound_Broadside(); 
       broadsideSound.play(); 

       //calculate damage to target ship, decide if this broadside targeted at hull or rigging 
       if ("broadsideFireButtonHull" == e.target.name) { 

        //1 hull, 2 rigging 
        targetObj.targetArea = 1; 
        calcGunDamage(1); 
       } 

       else { 
        //target is rigging 
        targetObj.targetArea = 2; 
        calcGunDamage(2); 
       } 
      } 
     } 

     //broadside confirm cancel button, clear map 
     function cancelButtonHandler(e: Event) { 

      clearGameMap(e.target); 
     } 

     //broadside confirm fire button rollover handler 
     function broadsideButtonRollOverHandler(e: Event) { 

      e.target.gotoAndStop('hover'); 
     } 

     //broadside confirm fire button rollover handler 
     function broadsideButtonRollOutHandler(e: Event) { 

      e.target.gotoAndStop('default'); 
     } 

편집 6/10 :에 말했을 때 결과 대화 상자가 떨어져 문제없이 간다. 이전에 누락 된 Broadside 결과 단계를 추가했습니다.

+0

답변 기능을 사용하지 않고보기를 첨부하는 방법이 표시되지 않습니다. 나는 첨부 된 두 가지가 중요한 것이라고 생각한다. 누락 된 대화를 누군가보아야 만한다면, 나는 대답을 사용할 것입니다. – vossiewulf

+0

당신이 표시 객체를 가지고 무엇을해야만하는지 기억하십시오, 당신은 표시 객체 트리를 사용하여'removeChild()'를 어디에서 찾을 지 결정할 수 있습니다. 기본적으로, 전체 객체를 제거하기를 원할 경우,'this.parent.removeChild (this)'는 100 % 도움이됩니다. – Vesper

+0

필자는 이미 똑같은 것을 시도해 보았습니다. 똑바로있는 removeChild (broadsideConfirmDialog) 라인을 broadsideConfirmDialog.parent.removeChild (broadsideConfirmDialog)로 바꾸면 아무런 차이가 없습니다. – vossiewulf

답변

1

제가 처음 옳았습니다. 실제로는 그 대화 상자의 별도 인스턴스였습니다.어젯밤에 다시 보았을 때 로그에 두 번 실행해서는 안되는 로그 섹션이 두 배로 있음을 알았습니다. 그리고 그것은 Broadside Confirm 대화 상자의 생성을 요구하는 함수입니다.

유효 대상이 아니었을 때 적선이 선택 가능한 엣지 케이스를 추적하기 위해 우주선 선택 기능에서 isValidTarget() 체크를 추가했으며, isValidTarget이 Broadside를 호출하기 때문에 유령 대화 상자로 끝났습니다 대상이 유효하면 대화 상자를 확인하십시오. isValidTarget에 모드 검사를 추가하여 수정했는데 여기에서 촬영하려고하는지 또는 대상 상태를 확인 중인지 여부를 알려주고 있습니다. 실제로는 그 논리의 일부로 시작해야합니다.

하나의 문제는 누군가가 알고 있다면 조언을 많이 주시면 감사하겠습니다 곳이 남아 있고, 그것은 우리가 디버거이 같은 클래스/대화의 여러 인스턴스를 감지 어떻게 입니까? 나는 이것을 게시하기 전에 두 번째 인스턴스인지 여부를 알아 내려고 디버거에서 30 분을 보냈다. 하나의 BroadsideConfirmDialog 변수 만 보았거나 적어도 그렇게 생각하면 범위 체인에서 혼란스러워진다.

+0

IIRC 거기에 FlashDevelop의 디버거에 클래스 인스턴스 카운터가 있습니다. 또한,이 사건은 당신의 다른 문제에 대한 단서가 될 수도 있습니다 "무언가"우주선, 무언가도 두 번 만들었습니다. – Vesper

+0

감사합니다 베스퍼, 한번보세요. – vossiewulf