11 Replies Latest reply on Jan 23, 2007 3:12 PM by kglad

    Button Problems

    SymTsb Level 2
      Hey guys and gals. I am working on a project where I have a main.swf that contains a graphic of a table with different products on it. Each of these products is a separate swf or flv file. I am using the MovieClipLoader class to load all of my movies into a movie clip in main.swf. This is all working fine and good.

      Inside 2 of these individual swfs, are buttons that pertain directly to there respective parent clips and their content.

      In the first file, the buttons have hit areas that more than cover the button area. However, it takes multiple passes over the button to get the mouse to detect the hit area.

      In the second file, the buttons are actually movie clips that load external sound clips when released. When this file is played as its own swf, the buttons and related AS work perfectly. When this movie is loaded into my main.swf mentioned above, these buttons no longer work more specifically, they react as a button would if you called btn1.enabled = false; However, this doesn't happen in the code for these movie clips.

      I know there are issues with nested buttons but my understanding of the issue was this....

      ==========
      | btn btn btn |
      ==========

      if the area around the button is a movie clip, with events being tested or carried out, you'll have to destroy the onEnterFrame to interact with the buttons below and then test the mouse position against the bounds of the mc to reinstate the onEnterFrame for the surrounding mc. I've used these principles to create numerous different content/thumbnail scrollers in the past.

      In the case of my current project, this wouldn't seem to be the case or is it? Can anyone tell me why my buttons and the associated events are working on their own but not when loaded into the main.swf???

      Thanks in advance.
      Mike
        • 1. Re: Button Problems
          kglad Adobe Community Professional & MVP
          usually a swf that works when run alone and fails when loaded is due to a path reference that changes when loaded. usually that problem can be solved by using:

          • 2. Re: Button Problems
            kglad Adobe Community Professional & MVP
            usually a swf that works when run alone and fails when loaded is due to a path reference that changes when loaded. usually that problem can be solved by using:

            • 3. Button Problems
              SymTsb Level 2
              I wish I could say that worked. I never thought about that either. Applied it to no avail. I'm going to include the AS from the external swf with the hopes that someone will see something I do not.



              • 4. Re: Button Problems
                kglad Adobe Community Professional & MVP
                when you instantiate your sound object try:

                • 5. Re: Button Problems
                  SymTsb Level 2
                  Thanks for the input on the sound. Can you see any reason why the movie's buttons would not work when loaded from the main.swf file? They work perfectly from the independent movie but not if the movie is loaded.
                  • 6. Re: Button Problems
                    kglad Adobe Community Professional & MVP
                    do you have mouse handlers defined for the target movieclip into which that external swf loads?
                    • 7. Button Problems
                      SymTsb Level 2
                      Yes I do. The main movie is an image of a table with 5 objects on it. Each of those 5 objects has an invisible button over them. Clicking on those buttons disables them and then loads the appropriate external swf file. The code for the main movie is attached below.

                      Each of the external clips that get loaded have buttons inside them with the exception of the dvd. The buttons for book1 and book2 work perfectly. Their handlers function as expected both as an independent clip and as an external clip. The buttons for cards give me an issue where it takes multiple passes over them to get them to initialize their event handlers but functions perfectly as an independent clip. The consult file's buttons don't work at all when loaded externally but work exactly as intended when played independently.

                      I know when a button is encapsulated inside a movie clip and both have events attached, you have to delete the events for the movie clip and then reload them after moving outside the bounds of that movie clip. In this case however, I didn't think that would be necessary. Is it and if so, why?
                      • 8. Re: Button Problems
                        kglad Adobe Community Professional & MVP
                        is there any relationship (parent-child) between holder and any of the movieclips (consult, dvd etc) that have onRelease handlers?

                        is there any code affecting holder that's not above?
                        • 9. Re: Button Problems
                          SymTsb Level 2
                          No kglad. All the code you see in both sections of attached code are all the code for both movies.

                          The first set of AS is the code present in consult.swf. There are two different chunks of code present here though. The first chunk should apply to the Enter button which tests a users entered password to confirm they can even view the rest of the consultation information. The second chunk is the code that is on Frame 1 in its own AS layer.

                          The second set of code is present in main.swf on Frame 1 in it's own layer.
                          • 10. Re: Button Problems
                            SymTsb Level 2
                            I found the solution to my problem. It has to do with the visibility of the underlying buttons in main.swf. It is not enough to simply disable them. By having their visible property set to false in the onLoadInit function in the MCL class, they no longer "appear" on the stage to receive events disabled or not.

                            Thank you for your help kglad.
                            • 11. Re: Button Problems
                              kglad Adobe Community Professional & MVP
                              are you waiting until password.txt loads before pressing your enter button? if so, post a link to your main fla and consult.fla.

                              also, you should consider using some kind of loop to ensure password.txt has completed loading before you enable the enter button.

                              that's not needed if this is going to be a proejctor file but if it's going online, it would be a good idea even though it would take an incredibly bad connection to have someone fill out your password textfield and press the enter button before the text file completed loading.