Skip to main content
Participating Frequently
December 14, 2015
Answered

A button that clicks on any layer even with filters on top?

  • December 14, 2015
  • 4 replies
  • 809 views

Hey guy. Im new to actionscript. The button click works, but the current project I have is colored by overylays on top. Apparently the AS code only works if there aren't any layers on top so far.

Is there a way to tell it to code on the top or any layer?

Im using this code BTW.


stop();

instanceName.addEventListener(MouseEvent.CLICK, functionName);

function functionName(event:MouseEvent):void

{

play();

}

This topic has been closed for replies.
Correct answer dmennenoh

What are the overlays? If they are png's or sprites with shapes in them you should be able to simply set mouseEnabled to false on them, and the underlyng button should work.

overlay.mouseEnabled = false;

Also look at mouseChildren.

4 replies

maeiounjAuthor
Participating Frequently
December 17, 2015

Hey guys, my teacher helped me out anyway and he did use the parent and child code. AS was being buggy but its fine now. Thanks for your help!

Inspiring
December 17, 2015

That's great. But ActionScript was not buggy - it was your code.

maeiounjAuthor
Participating Frequently
December 17, 2015

Well yes and no. See what happen was, I consulted my friend about how to place the button in front and that part worked. When I added more buttons on there, thats where AS broke down a bit. The instance name and the code was exact, but the arm only played the sound and stopped animating.

So i took it to my teacher, and he couldn't figure out why. So just  he just reattached all the code to the symbol and did the parent child thing. That worked. And then I coded the button for going back to  the previous scene. For Some reason AS at that point and time just only decide to restart the scene and play the sound when clicking that button.

And then when I got home and uploaded my SWF file to my Deviant art website, it worked for some reason. That was what I feel AS is buggy. Sometimes it isn't the code but the program sometimes feels a bit glitchy, or sometimes I also get confused only because the amount of symbols I used. So far Flash isn't great for organization for its symbols and that probably what messed me  up a bit.

dmennenohCorrect answer
Inspiring
December 14, 2015

What are the overlays? If they are png's or sprites with shapes in them you should be able to simply set mouseEnabled to false on them, and the underlyng button should work.

overlay.mouseEnabled = false;

Also look at mouseChildren.

maeiounjAuthor
Participating Frequently
December 15, 2015

Its a vector overlay. This project requires mostly vectors.

Inspiring
December 15, 2015

Like I said - Sprites with shapes. Did you try it?

Ned Murphy
Legend
December 14, 2015

One way to accomplish this is to use an invisible button and place it on top of all layers.

maeiounjAuthor
Participating Frequently
December 14, 2015

I agree, but again limited on what code to use for that or how to go to reference it.

Basically the button is actually a character where you click an object and then it does something thing. Im working within symbols.

rezun8
Inspiring
December 14, 2015

as Ned says, make an invisible button that lies on top of the symbol so it registers the interaction. You would set it up as a normal button just as if it were within the symbol your creating.

maeiounjAuthor
Participating Frequently
December 14, 2015

I mean so I can click the button on any layer.