# Disable the button for current page only

**URL:** <https://forum.kirupa.com/t/disable-the-button-for-current-page-only/290289>\
**Category:** flash\
**Created:** [June 12, 2009, 9:47am UTC](https://forum.kirupa.com/t/disable-the-button-for-current-page-only/290289 "2009-06-12T09:47:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gts85](https://avatars.discourse-cdn.com/v4/letter/g/edb3f5/32.png) [@gts85](https://forum.kirupa.com/u/gts85)\
**Post date:** [June 12, 2009, 9:47am UTC](https://forum.kirupa.com/t/disable-the-button-for-current-page-only/290289/1 "2009-06-12T09:47:09Z")

</div>

Hi all, I currently creating a website which content some pages. example of homepage and aboutpage.I want to make it as below.

If the user clicks the ‘home\_mc’ button i want it to disable to the content cant be loaded twice. If the user clicks ‘products\_mc’ i want ‘home\_mc’ to be enable again, and then disable ‘products\_mc’.This to prevent user to currently reading on homepage when click on the home\_mc button again will cause the homepage animate in again.

but i still cant figure out how to make it.  
can we use some code like  
if(nextPage == currentPage)  
{  
//disable the mouseEvent listener of the currentTarget button?  
}

thanks for helps…

```auto

menu_mc.home_mc.addEventListener(MouseEvent.CLICK, onClick);
menu_mc.about_mc.addEventListener(MouseEvent.CLICK, onClick);
 
var Home:HomePage = new HomePage();
var About:AboutPage = new AboutPage();
var currentPage:MovieClip = Home
var nextPage:MovieClip;
 
Home.x = About.x = 10.2;
Home.y = About.y = 523.8;
addChild(Home);
 
menu_mc.home_mc.mcTarget = Home;
menu_mc.about_mc.mcTarget = About;
 
function onClick(e:MouseEvent):void
{
 nextPage = e.currentTarget.mcTarget;
 removeChild(currentPage);
 addChild(nextPage);
 currentPage = nextPage;
 currentPage.gotoAndPlay(1);
 menu_mc.home_mc.removeEventListener(MouseEvent.CLICK, onClick);
 menu_mc.about_mc.removeEventListener(MouseEvent.CLICK, onClick);
 var myTimer:Timer = new Timer(3333.3333,1);
 myTimer.addEventListener(TimerEvent.TIMER, enable);
 myTimer.start();
}
 
function enable(e:TimerEvent):void
{
 menu_mc.home_mc.addEventListener(MouseEvent.CLICK, onClick);
 menu_mc.about_mc.addEventListener(MouseEvent.CLICK, onClick);
}

```
