# Adding/Removing movieclips that are nested

**URL:** <https://forum.kirupa.com/t/adding-removing-movieclips-that-are-nested/352034>\
**Category:** flash\
**Created:** [November 14, 2014, 5:41pm UTC](https://forum.kirupa.com/t/adding-removing-movieclips-that-are-nested/352034 "2014-11-14T17:41:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![good\_snow](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@good\_snow](https://forum.kirupa.com/u/good_snow)\
**Post date:** [November 14, 2014, 5:41pm UTC](https://forum.kirupa.com/t/adding-removing-movieclips-that-are-nested/352034/1 "2014-11-14T17:41:06Z")

</div>

So I’m trying to figure out how to create popup boxes within popup boxes. I have the first popup box figured out and I tried to just copy the code for the first box and just change the buttons and AS for the second one but I just get an error that says “duplicate function definition” for the loadMC part.

Here’s an example of what I’m trying to do and my AS code:

![](http://forum.kirupa.com/uploads/kirupa/7109/9c1b25db71cfcaf8.png)

```javascript
// -- ONLINE WORKFLOW --

//Order Prep Main
var OrderPrepOnlineMenuInstance:OrderPrepOnlineMenu = new OrderPrepOnlineMenu();
var mcOnStage:Boolean=false;
loadOrderPrepOnlineBtn.addEventListener(MouseEvent .CLICK, loadMC);
OrderPrepOnlineMenuInstance.OrderPrepOnlineClose.b uttonMode=true; OrderPrepOnlineMenuInstance.OrderPrepOnlineClose.a ddEventListener(MouseEvent.CLICK, removeMC);

function loadMC(e:MouseEvent):void {
addChild(OrderPrepOnlineMenuInstance);
OrderPrepOnlineMenuInstance.x = 465;
OrderPrepOnlineMenuInstance.y = 230;
mcOnStage=true;
}

function removeMC(e:MouseEvent):void {
if (mcOnStage ) {
removeChild(OrderPrepOnlineMenuInstance);
mcOnStage=false;
} 
}

//Order Prep - Inventory Grids
var InventoryGridsOnlineDescBoxInstance:InventoryGrids OnlineDescBox = new InventoryGridsOnlineDescBox();
loadIventoryGridsOnlineBtn.addEventListener(MouseE vent.CLICK, loadMC);
InventoryGridsOnlineDescBoxInstance.InventoryGrids Close.buttonMode=true; InventoryGridsOnlineDescBox.InventoryGridsClose.ad dEventListener(MouseEvent.CLICK, removeMC);

function loadMC(e:MouseEvent):void {
addChild(InventoryGridsOnlineDescBoxInstance);
InventoryGridsOnlineDescBoxInstance.x = 465;
InventoryGridsOnlineDescBoxInstance.y = 230;
}

function removeInventoryGridsMC(e:MouseEvent):void {
if (mcOnStage ) {
removeChild(InventoryGridsOnlineDescBoxInstance);
} 
}

```

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [November 14, 2014, 6:18pm UTC](https://forum.kirupa.com/t/adding-removing-movieclips-that-are-nested/352034/2 "2014-11-14T18:18:14Z")

</div>

You can’t have two functions of the same name in the same place in ActionScript. You’ll have to rename your copy(ies) to something else.

---

<div class="post-metadata">

**Author:** ![good\_snow](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@good\_snow](https://forum.kirupa.com/u/good_snow)\
**Post date:** [November 14, 2014, 7:54pm UTC](https://forum.kirupa.com/t/adding-removing-movieclips-that-are-nested/352034/3 "2014-11-14T19:54:38Z")

</div>

Yea, I’m just confused on which parts of the functions I need to change the name on?

---

<div class="post-metadata">

**Author:** ![good\_snow](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@good\_snow](https://forum.kirupa.com/u/good_snow)\
**Post date:** [November 14, 2014, 8:58pm UTC](https://forum.kirupa.com/t/adding-removing-movieclips-that-are-nested/352034/4 "2014-11-14T20:58:24Z")

</div>

So I’m no longer getting any error messages but I can’t get the second popup box to load?

Here’s my code now:

// – ONLINE WORKFLOW –

//Order Prep Main  
var OrderPrepOnlineMenuInstance:OrderPrepOnlineMenu = new OrderPrepOnlineMenu();  
var mcOnStage:Boolean=false;  
loadOrderPrepOnlineBtn.addEventListener(MouseEvent.CLICK, loadOrderPrepOnlineMenu);  
OrderPrepOnlineMenuInstance.OrderPrepOnlineClose.buttonMode=true; OrderPrepOnlineMenuInstance.OrderPrepOnlineClose.addEventListener(MouseEvent.CLICK, removeOrderPrepOnlineMenu);

function loadOrderPrepOnlineMenu(e:MouseEvent):void {  
addChild(OrderPrepOnlineMenuInstance);  
OrderPrepOnlineMenuInstance.x = 465;  
OrderPrepOnlineMenuInstance.y = 230;  
mcOnStage=true;  
}

function removeOrderPrepOnlineMenu(e:MouseEvent):void {  
if (mcOnStage) {  
removeChild(OrderPrepOnlineMenuInstance);  
mcOnStage=false;  
}   
}

//Order Prep - Inventory Grids  
var InventoryGridsOnlineDescBoxInstance:InventoryGridsOnlineDescBox = new InventoryGridsOnlineDescBox();  
var InventoryGridsOnlineDescBoxInstanceOnStage:Boolean=false;  
OrderPrepOnlineMenuInstance.loadInvGrids.addEventListener(MouseEvent.CLICK, loadInventoryGridsOnlineDescBox);  
InventoryGridsOnlineDescBoxInstance.InventoryGridClose.buttonMode=true; InventoryGridsOnlineDescBoxInstance.InventoryGridClose.addEventListener(MouseEvent.CLICK, removeInventoryGridsOnlineDescBox);

function loadInventoryGridsOnlineDescBox(e:MouseEvent):void {  
addChild(OrderPrepOnlineMenuInstance);  
InventoryGridsOnlineDescBoxInstance.x = 465;  
InventoryGridsOnlineDescBoxInstance.y = 230;  
InventoryGridsOnlineDescBoxInstanceOnStage=true;  
}

function removeInventoryGridsOnlineDescBox(e:MouseEvent):void {  
if (InventoryGridsOnlineDescBoxInstanceOnStage) {  
removeChild(InventoryGridsOnlineDescBoxInstance);  
InventoryGridsOnlineDescBoxInstanceOnStage=false;  
}  
}
