嵌套的动画片段;更改背景框架

时间:2016-06-06 03:28:45

标签: actionscript-3 movieclip

我所有的孩子都去了哪里?

希望这是对一个不那么聪明的问题的一个相对简单的答案,这是我在不做工作时学习东西的结果。在这种情况下,我在大约3年前在AS3开始了一个游戏,因为我至少熟悉js并且当天还使用了Shockwave。无论如何,当像这样离线学习时,我倾向于学习我需要知道的事情来做我接下来需要做的事情,并且有时可以在一个区域中进入相当远的地方而忽略了一些明显和简单的东西,因为我只是没有越过那个案子了。

我们有一个比赛场地和比赛场地。您在下面看到的那些玩具(帆船)是具有许多属性和几个孩子的复杂对象,包括根据船的状态而改变的图形和文本字段。它是WEGO,每个边块都会移动,然后这些移动一次又一次地在两边之间执行,然后我们就会进行枪战等等。一切都在那里工作正常,几千行代码

我目前的问题是,当玩家点击船只来选择它时,我取消隐藏黄色边框以指示选择了哪艘船并绘制了您在左上方看到的复杂船舶详细信息屏幕,但很长一段时间我都是&#39 ;我也想改变游戏片的背景颜色。

经过长时间的裁员后,我再次开始研究,决定从那里开始。所以我创建了新计数器,将它们作为关键帧添加到包含所有国家/地区默认背景的现有符号/类中,并修改了代码。它工作正常,因为背景更改为正确的突出显示版本,然后在取消选择时返回默认值。

在图像中,当前选择的船位于USS Constitution中心,其详细信息屏幕也会显示。 你可以看到这个问题,所有的孩子都在玩游戏。当你回到原来的默认背景时,他们不会回来。

起初我认为这是az命令问题但它不是,我走了选定的船在z索引中玩片背景,直到它们消失在海洋背景后面,只有开阔的海洋,那里的船只曾经是游戏。

我最好的猜测是,每次更改父母的框架时,孩子必须在父母的时间轴的每一帧上实例化,但如果是这样,我可能没有找到参考或对此的解释。这似乎是非常笨拙的做事方式,除非有编码逻辑告诉它,否则孩子们关心其父母所在框架的想法让我完全措手不及。

不知怎的,即使我有数千行复杂的对话框和屏幕显示多个动态孩子,但在任何一种情况下我都没有改变基本背景。

也尝试谷歌这个,但运气不好。我甚至无法想出一个相对简单的问题。

我很乐意粘贴代码,但我似乎没有代码问题,但理解问题。

Example-selected ship with highlighted background graphic is in the center

对于那些认为代码很重要的人来说,这是1500线船舶创建功能的结束,其中大部分孩子都被添加:

textShipSailSpeed.name = "textShipSailSpeed";
            textShipSailSpeed.width = 20;
            textShipSailSpeed.height = 13;
            textShipSailSpeed.x = 33;
            textShipSailSpeed.y = 14;
            textShipSailSpeed.embedFonts = true;
            textShipSailSpeed.textColor = 0xFFFFFF;
            textShipSailSpeed.rotation -= 90;

            //full sails set
            if ("full" == finalShip.sailState) {

                textShipSailSpeed.text = finalShip.fullSailSpeed;
            }

            //battle sails set, which are reduced sails to improve visibility and reduce sail damage in combat
            else {

                textShipSailSpeed.text = finalShip.battleSailSpeed;
            }

            // textShipBattleSailSpeed and textShipFullSailSpeed no longer used on counters, but still used in Info screens
            var textShipBattleSailSpeed: TextField = new TextField();
            textShipBattleSailSpeed.name = "textShipBattleSailSpeed";
            textShipBattleSailSpeed.text = finalShip.battleSailSpeed;
            textShipBattleSailSpeed.visible = false;

            var textShipFullSailSpeed: TextField = new TextField();
            textShipFullSailSpeed.name = "textShipFullSailSpeed";
            textShipFullSailSpeed.text = finalShip.fullSailSpeed;
            textShipFullSailSpeed.visible = false;

            //create sailState (battle/full) indicator
            var sailStateIndicator: WSIM_Counters_SailtState_Indicator = new WSIM_Counters_SailtState_Indicator();

            //set indicator to correct sailState background graphic
            sailStateIndicator.gotoAndStop("battle");

            if ("full" == finalShip.sailState) {

                sailStateIndicator.gotoAndStop("full");
            }

            finalShip.addChild(sailStateIndicator);

            //add ship and attach text fields
            gridBG1.addChild(finalShip);
            finalShip.addChild(textShipName);
            finalShip.addChild(textShipSailSpeed);
            finalShip.addChild(textShipTurnAllowance);
            finalShip.addChild(textShipBattleSailSpeed);
            finalShip.addChild(textShipFullSailSpeed);
            finalShip.parent.setChildIndex(finalShip, 1);

            //logging
            if (log_shipCreation) {

                trace(finalShip.name + " added added as child of background in createShip()");
            }

            //create background sprite "ship is selected" border
            var border: Sprite = new Sprite();
            border.name = "shipBorder";
            border.graphics.beginFill(0xFFCC00, 1);
            border.graphics.drawRect(-1, -1, 52, 132)
            border.graphics.endFill();
            border.visible = false;

            //create background sprite combat border
            var borderCombat: Sprite = new Sprite();
            borderCombat.name = "borderCombat";
            borderCombat.graphics.beginFill(0xFF0000, 1);
            borderCombat.graphics.drawRect(-1, -1, 52, 132)
            borderCombat.graphics.endFill();
            borderCombat.visible = false;

            //add the borders as children of ship
            finalShip.addChild(border);
            finalShip.addChild(borderCombat);

            //move the borders in z-order to behind ship counter, so they show looking like a border
            border.parent.setChildIndex(border, border.parent.getChildIndex(border) - 5);
            borderCombat.parent.setChildIndex(borderCombat, borderCombat.parent.getChildIndex(borderCombat) - 6);

            //PUSH TO MASTER SHIP ARRAYS
            //finalShip is Side 1, add to master list of ship objects for Side 1
            if (sideList[0] == finalShip.country) { ....

这是更大的selectShip功能的一部分,这里我清除地图上所有船只上的选定状态,然后将当前船舶的背景设置为currShip.country +" _sel&#34 ;这是"选择"的正确框架标签。背景图片。

//clear combat selected state on all ships
            for (var i: int = 0; i < shipListSide1.length; i++) {

                //hide selection border sprite and set select property false
                shipListSide1[i].combatSelected = false;
                var borderChildCombat = shipListSide1[i].getChildByName("borderCombat");
                borderChildCombat.visible = false;

                //show default counter background, build label name
                shipListSide1[i].gotoAndStop(shipListSide1[i].country+"_def");
            }

            for (var i: int = 0; i < shipListSide2.length; i++) {

                //hide selection border sprite and set select property false
                shipListSide2[i].combatSelected = false;

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

                //show default counter background, build label name
                shipListSide2[i].gotoAndStop(shipListSide2[i].country+"_def");
            }

            //check to see if this is selecting a target in gun combat
            if ((false == currShip.side1 && enableCombatSelectSide2) || (currShip.side1 && enableCombatSelectSide1)) {

                combatSelectShip(currShip);
            }

            //we're allowed to select this ship
            if ((enableSelectSide1 && currShip.side1) || (enableSelectSide2 && false == currShip.side1)) {

                //event is from a ship object
                if (currShip is Ship_1) {

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

                        currShipInfo.parent.removeChild(currShipInfo);
                    }


                    //clear selected state on all ships
                    for (var i: int = 0; i < shipListSide1.length; i++) {

                        //hide selection border sprite and set select property false
                        shipListSide1[i].selected = false;

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

                        //default graphic already set in clearing combatselect status above
                    }

                    for (var i: int = 0; i < shipListSide2.length; i++) {

                        //hide selection border sprite and set select property false
                        shipListSide2[i].selected = false;

                        var borderChild2 = shipListSide2[i].getChildByName("shipBorder");
                        borderChild2.visible = false;

                        //default graphic already set in clearing combatselect status above
                    }

                    //Change graphic of selected ship to selected, highlighted color
                    currShip.gotoAndStop(currShip.country+"_sel");

                    //set selected state on clicked ship, unhide border
                    currShip.selected = true;
                    borderChild = currShip.getChildByName("shipBorder");
                    borderChild.visible = true;

好的,根据有关它是一个z顺序问题的反馈,下面是我试图将失踪的孩子移回到游戏片背景之上。如果你注意到它也必须是一个z订单问题,因为&#34;选择&#34;边界,这是一个像缺失的玩具一样的孩子,碰巧故意在游戏图形的后面,当船舶处于选定状态时正确显示。查看原始屏幕截图,中心选中的游戏片并且缺少其子节点也有黄色边框。

无论如何,下面是我试过的。它的工作原理是没有错误但我真的无法在调试器中找到这些孩子以确认发生了什么,到目前为止我至少看起来已经将它们按照z顺序移动到最大值才能得到一个超出范围错误,问题仍然存在 - 没有船舶图形,船名,运动限额等。

//Change playing piece background of the selected ship to selected, highlighted color frame
                    currShip.gotoAndStop(currShip.country+"_sel");

                    //trying to move the children of the playing piece back above the playing piece graphic
                    var shipChildrenArray:Array = new Array("textShipName","textShipTurnAllowance","textShipSailSpeed","sailStateIndicator");

                    for each(var childItem:String in shipChildrenArray) {

                        currShip.setChildIndex(currShip.getChildByName(childItem), 3);
                    }

4 个答案:

答案 0 :(得分:1)

您的父级动画片段应该有图层。您希望始终可见的子动画片段需要扩展到父级的所有帧。

请注意,我没有看到你说我应该在你的图片上看到的内容。由于我不知道你认为它应该是什么样子,所以我无法发现它看起来和它之间的区别。

如果您发布时间轴的屏幕截图并发布所涉及的任何代码,您可能会发现您获得了更好的反馈。

答案 1 :(得分:0)

  

起初我认为这是一个z阶问题,但事实并非如此,

实际上这可能就是你的问题。

  

我走了选定的船在z指数中玩片背景,直到它们消失在海洋后面

真的?怎么样?在容器中移动显示对象的z顺序不能更改容器的z顺序。但是如果你正在移动船本身(所有其他符号的容器),那么是的,开放的海洋就会出现。但只是改变船内的东西不会那样做。如何在船舶集装箱内转移东西?转到here

实施例

如果你的游戏片段(pieceMc)是海洋背景(oceanMc)的孩子,并且旗帜背景(flagMc)是该片段的孩子那么

oceanMc.gamePieceMc.setChildIndex(flagMc,0);

应将标志置于底部

编辑6/11/16 在运行时更改z顺序的一种快速而又脏的方法是重新添加子项;它将被放在堆栈顶部。你可以做到

 piece[i].addChild(ship);
 piece[i].addChild(guns);
 piece[i].addChild(nameField);

结果将是船将到达顶部,然后枪将被放回到顶部,然后将名称放在顶部。如果国旗背景也是“片段”的孩子,它将在下面,就像你想要的那样。

答案 2 :(得分:0)

我尝试在这里构建一个简单的层次结构副本:

 package  {

    import flash.display.MovieClip;
    import flash.events.*;

    public class gameTestDoc extends MovieClip {
        var pieceArray:Array = new Array();

        public function gameTestDoc() {
            stage.addEventListener(MouseEvent.CLICK, selectPiece);
            for (var i:int = 0; i < 4; i++){ // creates 4 instances of a class with 6 frames, each having a different colored rectangle. 
                var gamePiece:MovieClip = new backGround();
                addChild(gamePiece);
                gamePiece.x = 50 * i + 200; // space out the game pieces. 
                gamePiece.y = stage.stageHeight/2; // center game pieces. 
                pieceArray.push(gamePiece);// add piece to array. 
                for (var j:int = 0; j < 5; j++){
                    var components:MovieClip = new MovieClip();
                    components.graphics.lineStyle();
                    components.graphics.beginFill(0x00ffcc * j * 200000); //gives different color to each component. 
                    components.graphics.drawRect(0,0,5, 10);
                    components.graphics.endFill();
                    gamePiece.addChild(components);
                    components.y = j * 5;                   
                }
                gamePiece.gotoAndStop(Math.ceil(Math.random()*10)); // give each piece a random frame to go to. 
            }
        }

        function selectPiece(e:MouseEvent):void{ // sends game piece frame to random frame. 
            for (var i:int = 0; i < pieceArray.length; i++){
                e.target.gotoAndStop(Math.ceil(Math.random()*10));
            }
        }
    }   
}

我在GUI库中有一个mc,链接名称为“backGround”。当我点击这些碎片时,背景会改变颜色,其他一切都会保持在最顶层。这是一张图片:

beforeClick 点击第2张后点击: enter image description here

你能从我的简单代码中看到你可能在做什么不同的事情吗?

编辑:6-10-16

    //move the borders in z-order to behind ship counter, so they show looking like a border
    border.parent.setChildIndex(border, border.parent.getChildIndex(border) - 5);
    borderCombat.parent.setChildIndex(borderCombat, borderCombat.parent.getChildIndex(borderCombat) - 6);

这不会让人感到困惑/容易出现奇怪的行为吗?:

    //move the borders in z-order to behind ship counter, so they show looking like a border
    border.parent.setChildIndex(border, 0);
    borderCombat.parent.setChildIndex(borderCombat, 0);

这不会给出相同的结果吗?

答案 3 :(得分:-1)

  

在运行时更改z顺序的一种快速而又脏的方法是重新添加子项;它将被放在堆栈顶部。你可以做[1] .addChild(船);件[1] .addChild(枪);件[1] .addChild(名称字段);结果将是船将到达顶部,然后枪将被放回到顶部,然后是名称之上。如果国旗背景也是&#34; piece&#34;它会在下面,就像你想要的那样。 - 昨天尼尔戴维斯

好的,这是我最接近的正确答案。正如您在原始问题的更新中所看到的,我尝试通过向上移动子项或向下移动子项来修复z顺序问题,但即使代码执行正常也没有运气。

所以我改变了我的解决方案:

//Change playing piece background of the selected ship to selected, highlighted color frame
                    currShip.gotoAndStop(currShip.country+"_sel");

                    //move the children of the playing piece back above the playing piece graphic. When parent changes frame as above it goes to the top of the z order for some stupid reason
                    var shipChildrenArray:Array = new Array("textShipName","textShipTurnAllowance","textShipSailSpeed","sailStateIndicator", "currShipGraphic");

                    for each(var childItem:String in shipChildrenArray) {

                        //currShip.setChildIndex(currShip.getChildByName(childItem), 5);
                        var childObject = currShip.getChildByName(childItem);
                        currShip.removeChild(childObject);
                        currShip.addChild(childObject);
                    }

对我而言,这似乎非常讨厌,我相当正确地操纵z顺序,但除非有人对如何做到这一点有其他想法,否则我们将不得不采用这种解决方案。重新添加子项确实会将它们移回当前z顺序数组的顶部。

所以:

1)如果你有嵌套的动画片段,你改变了父母的帧,它将会出现在z阶阵列的顶部,原因是我无法理解。我也没有办法预防它。

2)如果你知道如何比我更好地操纵儿童动画片段的z顺序,那可能是最好的解决方案。

3)大锤解决方案正在移除并添加所有孩子。

...它不会让我发布它正常工作的截图,因为我需要至少10个声望点来发布两个以上的链接。&#34;没有任何意义,因为这个附件是SECOND链接,而不是第三个或更多。哦,好吧。

回应尼尔的帖子。

看一下代码,我看到的唯一不同之处就是你将这些作品添加为舞台的孩子,而我的作为海洋图形的孩子则是一个嵌套的级别。

由于您对此感兴趣并花时间,我将在下面发布整个船舶创建功能。它被迭代地调用并循环通过side1 master数组的船只然后side2,背靠背。这是我对双方感到困惑的一个原因&#39; z命令始终不同,可能是按字母顺序排列 - 只有z命令操作我在创作中正在推动边框儿童(一个正常选择一个战斗)在游戏片后面。

顺便说一句,请问我还有另外一个问题涉及一个不同的问题,即在相关的代码未在几年内被触及的情况下,对话框拒绝在removeChild上消失。

这是船舶创造。这是一个模拟,而不是游戏,所以它设置了大量的属性,相当复杂。我会看到一个不寻常的事情是将我的Ship_1类投射到通用对象以设置所有自定义属性,然后在完成后返回Ship_1。我一直以为这有点风险,但已经看到零问题(除非这个问题与某种方式有关)

//create ship objects, set properties, add to core arrays
        function createShip(currShip) {

            // create Ship_1 obj and cast it temporarily as parent class (which is dynamic) to set custom properties
            var finalShip: Ship_1 = new Ship_1();
            var temp_Ship: Object = finalShip as Object;

            //set basic stats
            temp_Ship.selected = currShip.selected;
            temp_Ship.combatSelected = currShip.combatSelected;
            temp_Ship.name = currShip.name;

            //rigging & rigging damage
            temp_Ship.rigging = currShip.rigging;
            temp_Ship.riggingSlots = currShip.riggingSlots;
            temp_Ship.rigging_1 = currShip.rigging_1;
            temp_Ship.rigging_2 = currShip.rigging_2;
            temp_Ship.rigging_3 = currShip.rigging_3;
            temp_Ship.rigging_4 = currShip.rigging_4;
            temp_Ship.riggingDamage = currShip.riggingDamage;
            temp_Ship.riggingDamage_1 = currShip.riggingDamage_1;
            temp_Ship.riggingDamage_2 = currShip.riggingDamage_2;
            temp_Ship.riggingDamage_3 = currShip.riggingDamage_3;
            temp_Ship.riggingDamage_4 = currShip.riggingDamage_4;

            //hull & hull damage
            temp_Ship.hull = currShip.hull;
            temp_Ship.hull_1 = currShip.hull_1;
            temp_Ship.hull_2 = currShip.hull_2;
            temp_Ship.hull_3 = currShip.hull_3;
            temp_Ship.hullDamage = currShip.hullDamage;
            temp_Ship.hullDamage_1 = currShip.hullDamage_1;
            temp_Ship.hullDamage_2 = currShip.hullDamage_2;
            temp_Ship.hullDamage_3 = currShip.hullDamage_3;

            //guns & guns damage
            temp_Ship.guns = currShip.guns;
            temp_Ship.gunsDamage = currShip.gunsDamage;
            temp_Ship.guns_1 = currShip.guns_1;
            temp_Ship.guns_2 = currShip.guns_2;
            temp_Ship.guns_3 = currShip.guns_3;
            temp_Ship.guns_4 = currShip.guns_4;
            temp_Ship.gunsDamageLeftBow = currShip.gunsDamageLeftBow;
            temp_Ship.gunsDamageLeftBowInitial = currShip.gunsDamageLeftBowInitial;
            temp_Ship.gunsDamageRightBow = currShip.gunsDamageRightBow;
            temp_Ship.gunsDamageRightBowInitial = currShip.gunsDamageRightBowInitial;
            temp_Ship.gunsDamageLeftStern = currShip.gunsDamageLeftStern;
            temp_Ship.gunsDamageLeftSternInitial = currShip.gunsDamageLeftSternInitial;
            temp_Ship.gunsDamageRightStern = currShip.gunsDamageRightStern;
            temp_Ship.gunsDamageRightSternInitial = currShip.gunsDamageRightSternInitial;

            //carronades & carronades damage
            temp_Ship.carronades = currShip.carronades;
            temp_Ship.carronades_1 = currShip.carronades_1;
            temp_Ship.carronades_2 = currShip.carronades_2;
            temp_Ship.carronades_3 = currShip.carronades_3;
            temp_Ship.carronades_4 = currShip.carronades_4;
            temp_Ship.carronadesDamageLeftBow = currShip.carronadesDamageLeftBow;
            temp_Ship.carronadesDamageLeftBowInitial = currShip.carronadesDamageLeftBowInitial;
            temp_Ship.carronadesDamageRightBow = currShip.carronadesDamageRightBow;
            temp_Ship.carronadesDamageRightBowInitial = currShip.carronadesDamageRightBowInitial;
            temp_Ship.carronadesDamageLeftStern = currShip.carronadesDamageLeftStern;
            temp_Ship.carronadesDamageLeftSternInitial = currShip.carronadesDamageLeftSternInitial;
            temp_Ship.carronadesDamageRightStern = currShip.carronadesDamageRightStern;
            temp_Ship.carronadesDamageRightSternInitial = currShip.carronadesDamageRightSternInitial;

            //crew and crew damage
            temp_Ship.crewQuality = currShip.crewQuality;
            temp_Ship.crewDamage = currShip.crewDamage;
            temp_Ship.crew_1 = currShip.crew_1;
            temp_Ship.crew_1_damage = currShip.crew_1_damage;
            temp_Ship.crew_1_lost = currShip.crew_1_lost;
            temp_Ship.crew_1_lostInitial = currShip.crew_1_lostInitial;
            temp_Ship.crew_2 = currShip.crew_2;
            temp_Ship.crew_2_damage = currShip.crew_2_damage;
            temp_Ship.crew_2_lost = currShip.crew_2_lost;
            temp_Ship.crew_2_lostInitial = currShip.crew_2_lostInitial;
            temp_Ship.crew_3 = currShip.crew_3;
            temp_Ship.crew_3_damage = currShip.crew_3_damage;
            temp_Ship.crew_3_lost = currShip.crew_3_lost;
            temp_Ship.crew_3_lostInitial = currShip.crew_3_lostInitial;

            //initial positions, used in plotted movement
            temp_Ship.initialColumn = currShip.initialColumn;
            temp_Ship.initialRow = currShip.initialRow;
            temp_Ship.initialColumn2 = currShip.initialColumn2;
            temp_Ship.initialRow2 = currShip.initialRow2;
            temp_Ship.initialDirection = currShip.initialDirection;

            //movement properties
            temp_Ship.fullSailSpeed = currShip.fullSailSpeed;
            temp_Ship.fullSailSpeedArray = currShip.fullSailSpeedArray;
            temp_Ship.maxFullSailSpeed = currShip.maxFullSailSpeed;
            temp_Ship.initialFullSailSpeed = currShip.initialFullSailSpeed;
            temp_Ship.battleSailSpeed = currShip.battleSailSpeed;
            temp_Ship.battleSailSpeedArray = currShip.battleSailSpeedArray;
            temp_Ship.maxBattleSailSpeed = currShip.maxBattleSailSpeed;
            temp_Ship.initialBattleSailSpeed = currShip.initialBattleSailSpeed;

            //point of sailing (close reach, broad reach, etc.)
            temp_Ship.shipOrientation = currShip.shipOrientation;
            temp_Ship.movementAllowanceUsed = currShip.movementAllowanceUsed;
            temp_Ship.moveLog = currShip.moveLog;

            //turn properties
            temp_Ship.turnAllowanceBase = currShip.turnAllowanceBase;
            temp_Ship.turnAllowance = currShip.turnAllowance;

            //used in movement 
            temp_Ship.turnAllowed = currShip.turnAllowed;
            temp_Ship.moveAllowed = currShip.moveAllowed;

            //special conditions (anchored, grappled, etc.) can block movement/turning
            temp_Ship.canMove = currShip.canMove;
            temp_Ship.fouled = currShip.fouled;
            temp_Ship.anchored = currShip.anchored;
            temp_Ship.grappled = currShip.grappled;
            temp_Ship.onFire = currShip.onFire;

            //dismasted
            temp_Ship.dismasted = currShip.dismasted;
            temp_Ship.initialDismasted = currShip.initialDismasted;
            temp_Ship.dismastedPreviousValue = currShip.dismastedPreviousValue;

            //weapons status
            temp_Ship.loadedLeft = currShip.loadedLeft;
            temp_Ship.loadedRight = currShip.loadedRight;
            temp_Ship.shotType = currShip.shotType;

            //position
            temp_Ship.column = currShip.column;
            temp_Ship.row = currShip.row;
            //stern hex
            temp_Ship.column2 = currShip.column2;
            temp_Ship.row2 = currShip.row2;
            temp_Ship.direction = currShip.direction;

            //country
            temp_Ship.country = currShip.country;

            //class and rating
            temp_Ship.shipClassName = currShip.shipClassName;
            temp_Ship.shipClassNumber = currShip.shipClassNumber;
            temp_Ship.shipRate = currShip.shipRate;
            temp_Ship.originalGuns = currShip.originalGuns;

            //HACK need to find a better solution
            temp_Ship.combatBorderFixed = currShip.combatBorderFixed;

            //value will be frame label of the ship portrait we will use for this ship
            //these will be used by the info screens
            temp_Ship.portraitLabel = "";

            //      <--- begin select ship portrait for Info screens ---->

            //number of options per country + number of guns combo
            var portraitRandLimit:int = 1;

            //actual class that contains all of the ship portrait bitmaps
            var shipPortraitSource:Ship_Portrait = new Ship_Portrait;

            //pull list of all frame labels in shipPortraitSource
            var labelList:Array = shipPortraitSource.currentLabels;

            //iterate through list of frame labels to see if we have one that matches this ship's name
            for each (var frameObject:FrameLabel in labelList) {

                //we have a name match in our list of ship portraits, use specific bitmap for that individual ship
                if (frameObject.name == currShip.name) {

                    temp_Ship.portraitLabel = currShip.name;

                    //LOGGING
                    if (log_shipPortraitSelection) {

                        trace("==================================================");
                        trace("framObject.name: "+frameObject.name+" matched currShip.name: "+currShip.name);
                        trace("temp_Ship.portraitLabel set to: "+temp_Ship.portraitLabel);
                        trace("==================================================");
                        trace("");
                    }
                }
            }

            //we didn't find a name match, select a ship portrait from available options that match the ship country + number of guns it really carried
            //Trying to have 3-4 accurate options in each gun number + country combo
            if ("" == temp_Ship.portraitLabel) {

                //configure the number of options for each country + number of guns combo
                switch(currShip.country) {

                    case "US":

                        switch(currShip.originalGuns) {

                            case 44:
                                portraitRandLimit = 4;
                                break;
                            case 38:
                                portraitRandLimit = 4;
                                break;
                            case 36:
                                break;
                            case 32:
                                portraitRandLimit = 2;
                                break;
                            case 28:
                                portraitRandLimit = 2;
                                break;
                            case 16:
                                break;
                            case 12:
                                portraitRandLimit = 2;
                                break;
                        }

                        break;

                    case "GB":

                        switch(currShip.originalGuns) {

                            case 38:
                                portraitRandLimit = 4;
                                break;
                            case 36:
                                break;
                            case 32:
                                portraitRandLimit = 2;
                                break;
                            case 28:
                                portraitRandLimit = 3;
                                break;
                        }

                        break;  

                    case "FR":
                    case "ES":
                    case "NL":

                        break;
                }

                //now that we know how many options we have for this gun number + country combo, select one randomly
                var portraitNumber:int = Math.ceil(Math.random() * portraitRandLimit);

                //build the label name for us in the info screens, E.G., "GB_38_3", being the third portrait for 38 gun British ships
                temp_Ship.portraitLabel = currShip.country+"_"+currShip.originalGuns+"_"+portraitNumber;

                //LOGGING
                    if (log_shipPortraitSelection) {

                        trace("==================================================");
                        trace("There was no name match selecting a portrait, so building label name");
                        trace("currShip.name: "+currShip.name);
                        trace("portraitRandLimit: "+portraitRandLimit);
                        trace("portraitNumber: "+portraitNumber);
                        trace("temp_Ship.portraitLabel set to: "+temp_Ship.portraitLabel);
                        trace("==================================================");
                        trace("");
                    }
            }

            //      <--- end select ship portrait for Info screens ---->

            //used for movement rules, ship can only turn once per hex. 1 = straight, 2 = turn
            temp_Ship.lastMove = currShip.lastMove;

            //is ship fulll or battle sail
            temp_Ship.sailState = currShip.sailState;

            //designates which sdie ship is on
            temp_Ship.side1 = currShip.side1;
            temp_Ship.starboardHitZone = currShip.starboardHitZone;
            temp_Ship.portHitZone = currShip.portHitZone;
            temp_Ship.initialBroadside = currShip.initialBroadside;

            //ship going down
            temp_Ship.isSinking = currShip.isSinking;
            temp_Ship.isExploding = currShip.isExploding;

            //ship surrender
            temp_Ship.isSurrendered = currShip.isSurrendered;
            temp_Ship.strikeColors = currShip.strikeColors;
            temp_Ship.strikeFirePower = currShip.strikeFirePower;
            temp_Ship.strikeMobility = currShip.strikeMobility;

            //recast back to ship type. This seems risky but it works
            finalShip = temp_Ship as Ship_1;

            //calc initial positions based on column/row properties and a hex-based grid
            finalShip.x = (62 * (finalShip.column - 1)) + 17;

            //y setting is annoying
            finalShip.y = 5 + ((finalShip.row - 1) * 70) + ((finalShip.row - 1) * 1) - 71;

            //odd columns must compensate for half hexes
            if (1 == finalShip.column % 2) {
                finalShip.y += 35;
            }

            //rotate based on ship direction and correct for top left registration point
            switch (finalShip.direction) {

                case 1:
                    //do nothing
                    break;

                case 2:
                    finalShip.rotation = 60;
                    finalShip.x += 99;
                    finalShip.y += 27;
                    break;

                case 3:
                    finalShip.rotation = 120;
                    finalShip.x += 124;
                    finalShip.y += 129;
                    break;

                case 4:
                    finalShip.rotation = -180;
                    finalShip.x += 50;
                    finalShip.y += 202;
                    break;

                case 5:
                    finalShip.rotation = -120;
                    finalShip.x -= 51;
                    finalShip.y += 172;
                    break;

                case 6:
                    finalShip.rotation = -60;
                    finalShip.x -= 76;
                    finalShip.y += 72;
                    break;
            }

            //create ship graphics object. Numerous ship graphics representing all countries and all rates (1st-7th). There are multiple options in some country/rate cases
            var currShipGraphic:WSIM_Ship_Graphics = new WSIM_Ship_Graphics();

            //select correct background and ship graphics. Counter backgrounds are selected by ship country and ship rate sets the correct ship image to place on that background
            switch (finalShip.country) {

                //United States
                case "US":

                    //set US background
                    finalShip.gotoAndStop("US_def");

                    //Select correct ship overlay based on ship rating (1st-7th)
                    switch (finalShip.shipRate) {

                        //US had no ships of the line. Well there was America but she saw no action and was given to the French

                        //everything gets frigate for now
                        case 5:
                        case 6:
                        case 7:

                            currShipGraphic.gotoAndStop("US_5_1");
                            break;
                    }

                    break;

                //Great Britain
                case "GB":

                    //set GB background
                    finalShip.gotoAndStop("GB_def");

                    switch (finalShip.shipRate) {

                        case 1:

                            currShipGraphic.gotoAndStop("GB_1_1");
                            break;

                        case 2:

                            currShipGraphic.gotoAndStop("GB_2_1");
                            break;

                        case 3:

                            currShipGraphic.gotoAndStop("GB_3_1");
                            break;

                        case 4:

                            currShipGraphic.gotoAndStop("GB_4_1");
                            break;

                        //everything gets frigate for now
                        case 5:
                        case 6:
                        case 7:

                            currShipGraphic.gotoAndStop("GB_5_1");
                            break;
                    }

                    break;

                //France
                case "FR":

                    //set FR background
                    finalShip.gotoAndStop("FR_def");

                    switch (finalShip.shipRate) {

                        case 1:

                            currShipGraphic.gotoAndStop("FR_1_1");
                            break;

                        case 2:
                        case 3:

                            //we have multiple options for French 3rd rate SoL
                            var FR_shipGraphicRandom:int = Math.ceil(Math.random() * 2);

                            switch (FR_shipGraphicRandom) {

                                case 1:

                                    currShipGraphic.gotoAndStop("FR_3_1");
                                    break;

                                case 2:

                                    currShipGraphic.gotoAndStop("FR_3_2");
                                    break;
                            }

                            break;

                        case 4:

                            currShipGraphic.gotoAndStop("FR_4_1");
                            break;

                        //everything gets frigate
                        case 5:
                        case 6:
                        case 7:

                            currShipGraphic.gotoAndStop("FR_5_1");
                            break;
                    }

                    break;

                //Spain
                case "ES":

                    //set ES background
                    finalShip.gotoAndStop("ES_def");

                    switch (finalShip.shipRate) {

                        case 1:

                            currShipGraphic.gotoAndStop("ES_1_1");
                            break;

                        case 2:
                        case 3:
                        case 4:

                            currShipGraphic.gotoAndStop("ES_3_1");
                            break;

                        //everything gets frigate
                        case 5:
                        case 6:
                        case 7:

                            currShipGraphic.gotoAndStop("ES_5_1");
                            break;
                    }

                    break;

                //Netherlands
                case "NL":

                    //set NL background
                    finalShip.gotoAndStop("NL_def");

                    switch (finalShip.shipRate) {

                        case 1:
                        case 2:
                        case 3:
                        case 4:

                            currShipGraphic.gotoAndStop("NL_3_1");
                            break;

                        //everything gets frigate
                        case 5:
                        case 6:
                        case 7:

                            currShipGraphic.gotoAndStop("NL_5_1");
                            break;
                    }

                    break;
            }

            currShipGraphic.x = 0;
            currShipGraphic.y = 0;
            currShipGraphic.name = "currShipGraphic";

            //add correct ship graphic to the counter background
            finalShip.addChild(currShipGraphic);

            //font and format for counter text fields
            var arialFont = new Arial();
            var lucidaFont = new Lucida_Cal();

            var textShipNameFormat: TextFormat = new TextFormat();
            textShipNameFormat.size = 11;
            textShipNameFormat.font = lucidaFont.fontName;

            //ship name text field
            var textShipName: TextField = new TextField();
            textShipName.defaultTextFormat = textShipNameFormat;

            textShipName.name = "textShipName";
            textShipName.width = 80;
            textShipName.height = 13;
            textShipName.x = 34;
            textShipName.y = 105;
            textShipName.embedFonts = true;
            textShipName.textColor = 0xFFFFFF;
            textShipName.rotation -= 90;
            textShipName.sharpness = 200;
            textShipName.htmlText = "<p align='center'>" + finalShip.name + "</p>";

            //font format for movement and turn allowance
            var textShipNumbersFormat: TextFormat = new TextFormat();
            textShipNumbersFormat.size = 12;
            textShipNumbersFormat.font = arialFont.fontName;

            //ship turn allowance
            var textShipTurnAllowance: TextField = new TextField();
            textShipTurnAllowance.defaultTextFormat = textShipNumbersFormat;

            textShipTurnAllowance.name = "textShipTurnAllowance";
            textShipTurnAllowance.width = 20;
            textShipTurnAllowance.height = 13;
            textShipTurnAllowance.x = 33;
            textShipTurnAllowance.y = 127;
            textShipTurnAllowance.embedFonts = true;
            textShipTurnAllowance.textColor = 0xFFFFFF;
            textShipTurnAllowance.rotation -= 90;
            textShipTurnAllowance.text = finalShip.turnAllowance;

            //ship movement allowance AS DISPLAYED ON THE COUNTER - display either battle sails speed or full sails speed depending on ship state
            var textShipSailSpeed: TextField = new TextField();
            textShipSailSpeed.defaultTextFormat = textShipNumbersFormat;

            textShipSailSpeed.name = "textShipSailSpeed";
            textShipSailSpeed.width = 20;
            textShipSailSpeed.height = 13;
            textShipSailSpeed.x = 33;
            textShipSailSpeed.y = 14;
            textShipSailSpeed.embedFonts = true;
            textShipSailSpeed.textColor = 0xFFFFFF;
            textShipSailSpeed.rotation -= 90;

            //full sails set
            if ("full" == finalShip.sailState) {

                textShipSailSpeed.text = finalShip.fullSailSpeed;
            }

            //battle sails set, which are reduced sails to improve visibility and reduce sail damage in combat
            else {

                textShipSailSpeed.text = finalShip.battleSailSpeed;
            }

            // textShipBattleSailSpeed and textShipFullSailSpeed no longer used on counters, but still used in Info screens
            var textShipBattleSailSpeed: TextField = new TextField();
            textShipBattleSailSpeed.name = "textShipBattleSailSpeed";
            textShipBattleSailSpeed.text = finalShip.battleSailSpeed;
            textShipBattleSailSpeed.visible = false;

            var textShipFullSailSpeed: TextField = new TextField();
            textShipFullSailSpeed.name = "textShipFullSailSpeed";
            textShipFullSailSpeed.text = finalShip.fullSailSpeed;
            textShipFullSailSpeed.visible = false;

            //create sailState (battle/full) indicator
            var sailStateIndicator: WSIM_Counters_SailtState_Indicator = new WSIM_Counters_SailtState_Indicator();

            //set indicator to correct sailState background graphic
            sailStateIndicator.gotoAndStop("battle");

            if ("full" == finalShip.sailState) {

                sailStateIndicator.gotoAndStop("full");
            }

            sailStateIndicator.name = "sailStateIndicator";
            finalShip.addChild(sailStateIndicator);

            //add ship and attach text fields
            gridBG1.addChild(finalShip);
            finalShip.addChild(textShipName);
            finalShip.addChild(textShipSailSpeed);
            finalShip.addChild(textShipTurnAllowance);
            finalShip.addChild(textShipBattleSailSpeed);
            finalShip.addChild(textShipFullSailSpeed);
            finalShip.parent.setChildIndex(finalShip, 1);

            //logging
            if (log_shipCreation) {

                trace(finalShip.name + " added added as child of background in createShip()");
            }

            //create background sprite "ship is selected" border
            var border: Sprite = new Sprite();
            border.name = "shipBorder";
            border.graphics.beginFill(0xFFCC00, 1);
            border.graphics.drawRect(-1, -1, 52, 132)
            border.graphics.endFill();
            border.visible = false;

            //create background sprite combat border
            var borderCombat: Sprite = new Sprite();
            borderCombat.name = "borderCombat";

            //Great Britain ships are bright red, need to make combat border white
            if ("GB" == finalShip.country) {

                borderCombat.graphics.beginFill(0xFFFFFF, 1);
            }

            else {

                borderCombat.graphics.beginFill(0xFF0000, 1);
            }

            borderCombat.graphics.drawRect(-1, -1, 52, 132)
            borderCombat.graphics.endFill();
            borderCombat.visible = false;

            //add the borders as children of ship
            finalShip.addChild(border);
            finalShip.addChild(borderCombat);

            //move the borders in z-order to behind ship counter, so they show looking like a border
            border.parent.setChildIndex(border, border.parent.getChildIndex(border) - 5);
            borderCombat.parent.setChildIndex(borderCombat, borderCombat.parent.getChildIndex(borderCombat) - 6);

            //PUSH TO MASTER SHIP ARRAYS
            //finalShip is Side 1, add to master list of ship objects for Side 1
            if (sideList[0] == finalShip.country) {

                shipListSide1.push(finalShip);

                //logging
                if (log_shipCreation) {

                    trace(finalShip.name + " added to Shiplist1 in createShip()");
                }

            } 

            //Side 2, add to master list of ship objects for Side 2
            else {

                shipListSide2.push(finalShip);

                //logging
                if (log_shipCreation) {

                    trace(finalShip.name + " added to Shiplist2 in createShip()");
                }
            }

            //disable events on all children
            finalShip.mouseChildren = false;

            //ship selection event handler
            finalShip.addEventListener(MouseEvent.CLICK, selectShip);
        }