1 Reply Latest reply on Apr 20, 2009 8:56 AM by David Stiller

    Can Buttons Be Placed On Multiple Layers?


      Yesterday I was working on a Flash document that uses four buttons on the home page. First, let me say that I am new to Flash CS4 and have only been using it for about two months. Anyway, I decided to have the buttons move across the screen as the page loads. I created a different layer for each button. Then I created four different motion tweens that move each button onto the background. This all looks great but I have not yet added any actionscipt to tell the buttons what to do. As I was driving to work this morning, I began thinking about have the buttons on their own layer. For some reason, I wondered if this would work? Somehow in my mind, it seemed like the buttons might have to be on the same layer and that the layer would have to be on "top" for the buttons to work. Will a button still work or be "clickable" if it is on a lower layer? This is all new to me and maybe I am thinking too three dimensionally and it is making things more complex than they need be!  Thanks!

        • 1. Re: Can Buttons Be Placed On Multiple Layers?
          David Stiller Level 2



               Layer position doesn't necessarily affect the "clickability" of button symbols.  As a general rule, what matters is whether or not the button is obscured.  For example, if you position a button's layer lower in the stack -- and if doing so places the behind behind some other element -- that might keep the button from working, but even that depends on a couple of factors, including what version of ActionScript you're using and whether or not the asset above (the one that obscures) is also programmed to intercept mouse interaction.


               Fortunately, this is easy to test!    It's probably a good idea, too, to make a handful of small test-case FLA files that illustrate a particular concept in isolation.  Create a new FLA and draw a quick shape.  Convert that to a button, then position the button behind another shape in a layer of its own -- in the same layer as the shape -- then convert the shape to a graphic symbol, to a movie clip symbol, to a button symbol ... you get the idea.  In short order (say, within 15 minutes) you'll get acclimated and learn how various symbols interact with one another.


          > Anyway, I decided to have the buttons move across the screen as

          > the page loads. I created a different layer for each button.


               Because you're animating these buttons, you did right to put each symbol on its own layer.  Given the rest of your design, it may make sense to put those layers above the others, but again, a quick bit of testing will let you know for sure.  As a matter of convenience, I recommend you create a layer just for ActionScript, name it something like "code" or "scripts", and position that layer on top of everything else.  By having it on top, you'll always know where your programming is (no matter how many layers appear under it), and you won't have to scroll around to find it.  You can put all your code in one layer, and have it "reach out" to any other layer (such as your button layers) to communicate with objects in those layers.



          David Stiller
          Co-author, Foundation Flash CS4 for Designers
          "Luck is the residue of good design."