Copy link to clipboard
Copied
Hi,
I am very new to Flash, and I would really appreciate your help with my website. I am using Adobe Flash CS5, Action Script 3.0, and I want to disable my "home" movieclip after it has been clicked, so it stays a certain color or design that can't be clicked anymore. I already created the _up, _over, _down, and _disabled in the "home" timeline, and I don't know what to do after that.... i tried home.enabled = false, but it's already disabled when I hover to it. These are my codes so far:
stop();
home.stop();
home.buttonMode = true;
home.addEventListener( MouseEvent.CLICK, click_home );
function click_home(e):void{
gotoAndStop("home");
}
Thank you very much... and hope to hear from someone
-Cedrik
the code i showed will make your button not-function after it's clicked. if you want your button to also not look like it's clickable, , use:
stop();
home.stop();
home.buttonMode = true;
home.addEventListener( MouseEvent.CLICK, click_home );
function click_home(e):void{
home.removeEventListener( MouseEvent.CLICK, click_home );
home.buttonMode=false;
home.alpha=.5
gotoAndStop("home");
}
Copy link to clipboard
Copied
stop();
home.stop();
home.buttonMode = true;
home.addEventListener( MouseEvent.CLICK, click_home );
function click_home(e):void{
home.removeEventListener( MouseEvent.CLICK, click_home );
gotoAndStop("home");
}
Copy link to clipboard
Copied
Hi,
Thanks, but it didn't make the "home button" unclickable or disabled after it has been clicked. But, when i go to other pages, home is not clickable anymore. I just need to disable the button when I'm in that "home" page, and access home again after navigating to other pages.
Thank you.
Copy link to clipboard
Copied
You could set buttonMode to false in your timeline frame "home", and set it true in elsewhere
Copy link to clipboard
Copied
What kglad said is the right way - and unless you're adding the click listener again, removing the listener in the event handler would definitely disable the button. And setting buttonMode to true/false just makes the hand appear or not, it doesn't prevent the listener from firing.
Copy link to clipboard
Copied
Sorry - yes that's true, regardless of buttonMode the event listener receives MouseEvent. (Although if it's set to false you cannot invoke the click event with keyboards.) I usually would not add/remove event listener on every click though. Instead I'd react to the event differently, e.g. in this case if you are in "home" do nothing on click. As always there are more than one ways.
Copy link to clipboard
Copied
the code i showed will make your button not-function after it's clicked. if you want your button to also not look like it's clickable, , use:
stop();
home.stop();
home.buttonMode = true;
home.addEventListener( MouseEvent.CLICK, click_home );
function click_home(e):void{
home.removeEventListener( MouseEvent.CLICK, click_home );
home.buttonMode=false;
home.alpha=.5
gotoAndStop("home");
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now