# Close and open action

**URL:** https://forum.kirupa.com/t/close-and-open-action/288987
**Category:** Uncategorized
**Created:** [May 24, 2009, 5:29pm UTC](https://forum.kirupa.com/t/close-and-open-action/288987 "2009-05-24T17:29:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![drakkonblade](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@drakkonblade](https://forum.kirupa.com/u/drakkonblade)
#### Post date: [May 24, 2009, 5:29pm UTC](https://forum.kirupa.com/t/close-and-open-action/288987/1 "2009-05-24T17:29:11Z")

</div>

Hello,

```
   I wrote this code that loads and unloads object to the screen. But have small issue. When i press the CityButton it loads the object... i dont want the villageButton or anything to be selectable until the CityButton is pressed again which causes the loaded city object to be removed.

```

look at the code below to understand more.

thank you

/_//this is the button events for each name_/  
cityButton.addEventListener(MouseEvent.CLICK, clickHandler);  
villageButton.addEventListener(MouseEvent.CLICK, clickHandler2);

/_this is the boolean that decides if all is true or false when obj loaded  
also creat class of object_/  
var isThere:Boolean = false;  
var isThere2:Boolean = false;  
var mcHandle:MovieClip = new dahelpbox();  
var mcHandle2:MovieClip = new dahelpbox2();

//position the textbox eli  
mcHandle.x = 100;  
mcHandle.y = 100;  
mcHandle2.x = 100;  
mcHandle2.y = 100;

/_//this is the conditions to load or unload object depending if it  
meets the required requirements to load._/  
function clickHandler(e:MouseEvent):void {  
if (!isThere) {  
addChild(mcHandle);  
isThere = !isThere;  
} else {  
removeChild(mcHandle);  
isThere = !isThere;  
}  
}  
function clickHandler2(e:MouseEvent):void {  
if (!isThere2) {  
addChild(mcHandle2);  
isThere2 = !isThere2;  
} else {  
removeChild(mcHandle2);  
isThere2 = !isThere2;  
}  
}
