5 Replies Latest reply on Jan 11, 2007 11:57 AM by abeall

    does use of mask layer require re-estab of functions

    SPGAnne
      Am I missing something/doing something wrong, or is this the way Flash works?

      I have 2 buttons in a movieclip which is on the main timeline. The buttons are on a layer with a mask layer above it. On the main timeline I define 2 functions clip_mc.button1_btn.onRelease = function()... and clip_mc.button2_btn.onRelease = function().... The movie clip has 2 frames. Frame 1 has button2_btn masked out (i.e. not visible). Frame 2 has BOTH buttons visible.
      When I click on button1_btn the function says to gotoAndStop at frame 2 of the movieclip. Now button 1 .onRelease no longer works AND button2 .onRelease also does not work. I scratched my head about this a long time, did a pile of trace statements and couldn't figure out why. Then I put my 2 buttonN_btn.onRelease functions inside a function called initButtons(). Now after I gotoAndStop at frame 2, I call the initButtons() function again and the buttons work. This makes me wonder if this is really right, or if I am doing something wrong with the mask layer.

      Any help would be greatly appreciated.
        • 1. Re: does use of mask layer require re-estab of functions
          abeall Level 3
          Changing mask does seem to purge/re-instantiate symbols for some reason. Try making the elements on the mask layer be the same, just transformed. ie, don't delete or add any elements on different keyframes. Those sorts of changes seem to clear the symbol at that keyframe.
          • 2. Re: does use of mask layer require re-estab of functions
            SPGAnne Level 1
            Thanks for your helpful reply. At least I'm not doing something really dumb.

            I think I tried your suggestion, and I still seem to need to reinitialize the functions. Specifically, I put button1 and button2 next to each other on a layer. Above that I have a mask layer which has a rectangle. I used the transform tool to make the rectangle shorter on frame one so as to be only on top of button1 and then on frame 2 I made the rectangle long enough so that is on top of both buttons. Again, I seemed to have to reinit the functions. Oh well.

            Then I thought maybe I should use a regular layer to just blot out the button I don't want to see on frame 1 using the background color the button is on, and I found that while the button doesn't appear to be visible, it still responds to mouse events, so I also need to set _visible property in actionscript to be false. So seems like either way, you have to do a little more work in actionscript than I would've thought. Not a showstopper, it's just when I think I'm starting to get the hang of things, I seem to have to stumble around a lot on these little things, learning the hard way. ugh.
            • 3. Re: does use of mask layer require re-estab of functions
              abeall Level 3
              Sounds like you did the only thing I know to fix these kinds of problems, assuming that nothing else has changed, such as the button instance name or symbol. Again, transforms shouldn't matter. Just to clarify, if you delete the mask do you not have to re-define the functions on the buttons?

              To get around the interactive problem with the cover solution, put a solid colored MovieClip over top, and give it an event. It will steal any interactivity from symbols below it. I like to use:
              onRollOver = function(){
              this.useHandCursor = false;
              }
              So that the invisible button 1) steals any events from objects below it, and 2) doesn't show the hand cursor when the user is over it.

              Alternatively, you might try using the drawing API and setMask() instead.

              > I seem to have to stumble around a lot on these little things, learning the hard way
              Don't we all; Flash is like that ;-) We love it anyway, though!
              • 4. Re: does use of mask layer require re-estab of functions
                SPGAnne Level 1
                Thank you again for your prompt and helpful reply. Indeed, when I delete the mask layer, I do NOT need to reinit the button functions. I understand your solution too. So I guess it's just a matter of preference, unless you think one would perform the best.

                WRT my bumbling around. I VERY much appreciate the willingness to help and infinite patience of the experts on this forum, so I try to keep any whining and frustration to a minimum. However, I am an old mTropolis user, and I miss many aspects of that product soooo much. Flash seems way more difficult than that. Though I've been at it for some months now, and have purchased and read cover to cover both Moock books and try to read all the help over and over, I'm still having a very hard time adjusting and thinking in the Flash way, not to mention these little bumps in the road like this one. Maybe I'm just a slow learner. One of my biggest lingering issues is how to architect larger projects. I am trying as much as possible to do things using Classes and good OO design principles. Do you have any articles or books you would recommend that might help with that?

                Thanks again.
                • 5. Re: does use of mask layer require re-estab of functions
                  abeall Level 3
                  Flash is a beast, for sure, but it has a very unique pedigree which has attributed both to it's almost incomprehensible internet success, as well as oddities you don't see else where. Don't really have any book tips -- I'm actually a pretty meager developer myself, I've just been deeply submersed in Flash for the past 4 years so I know quite a bit by now.

                  A few other options:
                  1) Use Classes(since you mentioned that) for each button. Hopefully they won't reconstruct themself, but at least you won't have to manually.

                  2) Put the code inside the symbol. I actually do this a lot, but its not very clean depending on how you look at it(I personally think its clean and portable, but I'm in the minority there). Same deal as the class, the code will go with the symbol.