Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do i disable a movieclip after clicking it?

Guest
Jan 25, 2011 Jan 25, 2011

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

TOPICS
ActionScript
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 26, 2011 Jan 26, 2011

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");

}

Translate
Community Expert ,
Jan 25, 2011 Jan 25, 2011

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");

}


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 25, 2011 Jan 25, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 26, 2011 Jan 26, 2011

You could set buttonMode to false in your timeline frame "home", and set it true in elsewhere

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 26, 2011 Jan 26, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 26, 2011 Jan 26, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 26, 2011 Jan 26, 2011
LATEST

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");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines