10 Replies Latest reply on Apr 27, 2016 12:19 PM by ClayUUID

    A specific button isn't working on a specific keyframe

    spencerj91787822

      Hello,

      I am trying to do a Choose Your Own Adventure game for school and I'm running into a problem where one of my buttons will not respond. I've asked my teacher but she is also stumped as to how to fix the issue. I've double checked and triple checked my instance names and the buttons work on other keyframes and other buttons work on the keyframe I'm having problems with.

       

      I'm using a PC, but it also didn't work on the Macs at school.

       

      Any help would be appreciated.

       

      Here is a copy of my file to give a better understanding of the issue. The issue arises when you go to the Warrior page.

      spencerInteractiveAssignment.fla - Google Drive

        • 1. Re: A specific button isn't working on a specific keyframe
          Ned Murphy Adobe Community Professional & MVP

          Which button does this concern?  What should it do that other buttons do?  Have you tried putting a trace() function in the event handler function for the button to see if it reacts at all when it is used?  Where is the code located relative to the button?

          • 2. Re: A specific button isn't working on a specific keyframe
            robdillon Most Valuable Participant

            I looked at your file. I'm guessing that the problem is with the goToAsylum_btn that is labeled "Next". When I test the movie, I get a 1009 error. In looking through the code on frame 1 everything "seems" to be in order. Look at the items in the ButtonPlaceholder layer. In the first frame, you have four "Next" buttons. In the subsequent keyframes, there are only 3.

            • 3. Re: A specific button isn't working on a specific keyframe
              spencerj91787822 Level 1

              That was what my teacher said the problem was but even when I put the buttons on the first frame they still don't work.

              • 4. Re: A specific button isn't working on a specific keyframe
                spencerj91787822 Level 1

                It concerns the Next button on the Warrior page, frame 121.

                It should send you to the Asylum page, frame 151.

                I put a trace command in and it doesn't respond. In fact it doesn't even register the click because the button doesn't even go to it's "Hit" color.

                The code is all on frame 1. I've updated it some since I uploaded it so it doesn't have the trace command but the relavent lines are on Actions Frame 1 Lines 22-25

                • 5. Re: A specific button isn't working on a specific keyframe
                  Ned Murphy Adobe Community Professional & MVP

                  You will know better than myself, but I think the problem stems from you not having the buttons continuous along the timeline.  What I mean is that you appear to have left the next button on the Warrior page out of all the sections that precede it except frame 1's section.  In doing that you have disconnected the code in frame 1 from the button in the warrior section.  The code has to be assigned to the button and if it disappears from the timeline it also loses that connection - its name alone does not tie it to the code.

                   

                  Here is a different approach that might make it easier for you to manage...  have the buttons layer be one continuous set of frames instead of breaking it with a keyframe for each section.   In frame 1 place all of the buttons in their place.  In the actions layer make use of the 'visible' property to control which buttons are visible in the different frames.  You could even have a function that you share for them all that first hides them all and then sets the one passed to that function to be visible.  Alternately, you could just have code at the start of each section that adjusts the visible properties for all of them as needed.

                   

                  If you move that Next button onto the stage in frame 1 you will see it works properly.

                  1 person found this helpful
                  • 6. Re: A specific button isn't working on a specific keyframe
                    ClayUUID Adobe Community Professional

                    Ned Murphy wrote:

                     

                    You will know better than myself, but I think the problem stems from you not having the buttons continuous along the timeline.

                     

                    That is absolutely what the problem is. All those events are only assigned to the initial instances of the buttons. The moment that first keyframe hits, as far as Flanimate is concerned it's now a completely new set of buttons (that coincidentally happen to have the same names).

                     

                    Agreed that the correct way to do this is to have the buttons continuous across the entire adventure. He could then write a set of global helper functions to configure their label and destination at each step. For example, each "page" of the adventure could have something like:

                     

                    configButton(choice1btn, "Play", "classChoice");

                    • 7. Re: A specific button isn't working on a specific keyframe
                      spencerj91787822 Level 1

                      But then why does everything else up to that point work?

                      • 8. Re: A specific button isn't working on a specific keyframe
                        spencerj91787822 Level 1

                        I'm kind of a novice when it comes to this type of code. I'll see if my teacher can help me set this up.

                        Thank you very much.

                        • 9. Re: A specific button isn't working on a specific keyframe
                          Ned Murphy Adobe Community Professional & MVP

                          I cannot answer for Animate CC since I do not use it, but for Flash it has always been a case where if you have objects continuous along a timeline they will remain those objects even if you break them with keyframes at different points.  This can work to your advantage in some cases, but in other cases it can cause what you intend to be a different object to be the same object.  For instance, if you took that button and placed it on two adjacent keyframes, and only assigned it an instance name in the first frame, the second one would still acquire that instance name by some weird Flash osmosis.  Similarly, if you named the second one but did not name the first one, the second one would lose the name you assigned it due inheriting the property of the first.  That is why some of the buttons worked... you have them continuous in the different keyframes involved.  But in this Warrior case you broke that connection.

                          • 10. Re: A specific button isn't working on a specific keyframe
                            ClayUUID Adobe Community Professional

                            Yeah, Flash tries to figure out when an object is still itself so that tweens can work, but it doesn't always work, so should never be relied upon when things are instantaneously jumping around to different parts of the stage.

                             

                            Also, even if this approach did work reliably, it would still be the wrong approach because it scales terribly. It requires creating unique button instances for every single stage of the adventure.