# Handling CLICK event

**URL:** <https://forum.kirupa.com/t/handling-click-event/322383>\
**Category:** flash\
**Created:** [May 19, 2011, 8:01pm UTC](https://forum.kirupa.com/t/handling-click-event/322383 "2011-05-19T20:01:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![revo999](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@revo999](https://forum.kirupa.com/u/revo999)\
**Post date:** [May 19, 2011, 8:01pm UTC](https://forum.kirupa.com/t/handling-click-event/322383/1 "2011-05-19T20:01:46Z")

</div>

Hi

on clicking the Search Icon , a search bar will be visible (ON)

if user click anywhere on the stage the search bar will be NO visible(OFF) OR user click on ICON again the search bar will be OFF

**but it Stage CLICK is triggered without clicking**

```auto
searchIcon.addEventListener(MouseEvent.CLICK, showSearch);

var srchBox:Boolean = true;

function showSearch(event:MouseEvent):void
{
	if(srchBox)
	{
		srch.visible = true;
		stage.addEventListener(MouseEvent.CLICK, offSearch);
		srchBox = false;
	}
	else{
		
		srch.visible = false;
		srchBox = true;
		stage.removeEventListener(MouseEvent.CLICK, offSearch);
		
	}
	
	
	
}

function offSearch(event:MouseEvent):void
{
	
	srch.visible = false;
	stage.removeEventListener(MouseEvent.CLICK, offSearch);
}

```

**as I click on ICON , stage Icon triggerd, and search bar \> OFF**
