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

How to prevent click through?

Explorer ,
Dec 10, 2009 Dec 10, 2009

Basically I have mulitple buttons on the stage. Every button on the stage is an instance of the same component. When one of the buttons is pushed, that component imports an MC from the library to the stage (popup window). It then creates a text box and imports text into the box based on the XML settings typed in that components component inspector. The problem I keep running into is that I can still push the other component buttons through the mc that was imported to the stage.

I've tried the old way of fixing it.  ie. make a button the size of the popup window and put it behine the window.  This doesn't work.

I've tried using

stage.mouseChildren = false;

but that turns all the clicks off.  Even the one that the user needs to close the popup window.  I'm at a loss now.  Any help you can give is much appreciated.

TOPICS
ActionScript
696
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
Dec 10, 2009 Dec 10, 2009

Well, it's a matter of design - there are various ways to tackle this. But putting a button behind the pop-up will work. But it needs mouse event listeners attached so it intercepts the clicks. Use a shape instantiated from the library, or simply draw one with the graphics API, and then attach listeners. That does work...

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
Explorer ,
Dec 11, 2009 Dec 11, 2009

I'm not sure why.  But adding a button behind it isn't working for me.  Maybe it has something to do with the fact that all the buttons are components or maybe because all their instances of the same component.  I don't know.

Is there a way the components can speak to eachother?  Maybe I can set a global boolean value.  When a button is clicked it sets it to true.  Then if another button is clicked it checks to see if its true or false.  It won't open if its true.

I don't know.

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
Dec 11, 2009 Dec 11, 2009

Sorry, I never use the button component... If you make a movie clip with a shape in it the size of your stage and use that as a mouse blocker, it will work. You just need to give it a CLICK listener for it to 'absorb' clicks and not let them pass through.

Are you sure, when you try this your blocker is above the other buttons you're trying to block?

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
Explorer ,
Dec 11, 2009 Dec 11, 2009
LATEST

It seems my problem is, each component has a button that's controlled by code in the components class. When the button is pushed, code in the components class creates an MC on the stage (the popup window). For some reason, even though the new MCs were created last, the buttons are still on top of the MC. Is there a way to fix this?

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
Advocate ,
Dec 11, 2009 Dec 11, 2009

Are you adding the event listener to the individual buttons or the stage or what? Seems like you could add it to a containing sprite and evaluate whether or not you want the other ones active at the time with a allowClick flag or something. Or am I not reading the problem correctly.

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