# Selecting a specific Child by mouseclick, turning off a child within all non selected

**URL:** <https://forum.kirupa.com/t/selecting-a-specific-child-by-mouseclick-turning-off-a-child-within-all-non-selected/320299>\
**Category:** flash\
**Created:** [March 19, 2011, 7:28pm UTC](https://forum.kirupa.com/t/selecting-a-specific-child-by-mouseclick-turning-off-a-child-within-all-non-selected/320299 "2011-03-19T19:28:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xandat](https://avatars.discourse-cdn.com/v4/letter/x/9de0a6/32.png) [@Xandat](https://forum.kirupa.com/u/Xandat)\
**Post date:** [March 19, 2011, 7:28pm UTC](https://forum.kirupa.com/t/selecting-a-specific-child-by-mouseclick-turning-off-a-child-within-all-non-selected/320299/1 "2011-03-19T19:28:27Z")

</div>

I’ve used this site as a resource leading up to this, not particularly sure if I worded this correctly, hopefully someone can help.

I have a class “Block” which is just a square (will be something else later on in the process) I want each block to have controls to add an additional block in either direction so I have another class BlockButtons which has my buttons for each direction.

And another class GlobalVar where I keep all my variables for funsies

Here is my Code

```auto

// Main Block function in Block Class

		public function Block() 
		{
		this.x = GlobalVar.nPW
		this.y = GlobalVar.nPH
		this.addEventListener(MouseEvent.CLICK, BlockSelected);
		
		
//Adds Controls to Block		
		var NewBlockButtons:BlockButtons = new BlockButtons();
		
		addChild(NewBlockButtons);
//Buttons which create new blocks		
		NewBlockButtons.Mright.addEventListener(MouseEvent.CLICK, NewBlockFunction);
		NewBlockButtons.Mup.addEventListener(MouseEvent.CLICK, NewBlockFunction);
		NewBlockButtons.Mleft.addEventListener(MouseEvent.CLICK, NewBlockFunction);
		NewBlockButtons.Mdown.addEventListener(MouseEvent.CLICK, NewBlockFunction);

```

```auto

//Creates NewBlocks
public function NewBlockFunction(event:MouseEvent):void 
		{
		
		
		GlobalVar.oPW = GlobalVar.nPW
		GlobalVar.oPH = GlobalVar.nPH
		GlobalVar.nPW = event.target.x;
		GlobalVar.nPH = event.target.y;

   		var NewBlock:Block = new Block();
		
		
		addChild(NewBlock);
		}

```

Ok this next bit is in the BlockButtons Class

```auto
	public class BlockButtons extends MovieClip{
		
		public function BlockButtons() 
		{
		this.x = 0
		this.y = 0
		trace(1);

			
		}

	}

```

The buttons themselves are inside the movieclip BlockButtons.

So what I need is a way to hide all BlockButtons Except for the selected block. and also make the most recently created block THE selected block.

I had this working somewhat when I had the buttons inside the Block MC and was turning them off with .visible=false and true. however I could not find a way to turn off any that weren’t turned off by creating a new block.
