9 Replies Latest reply on Jun 3, 2010 10:06 AM by darling67

    Scripting mystery


      Ok, so I've got a movie clip with a 1st frame which is acting like a "home page" for purposes of this thread. In frames 2-4, I've got three sub-clips which play when prompted by buttons placed on a "buttons" layer in frame 1. In this "buttons" layer, there is a "back" button which appears on frame 2-4 and takes the viewer from frames 2-4 back "home" (to frame 1).


      The "back" button sends me back to frame 1 (home) when I am on the frame 2 sub-clip, but it doesn't take me "home" from the clips on frames 3-4.


      Here's my script which is working for frame 2's sub-clip, but won't work for frames' 3-4 sub-clips:





      function goFrame1(Event:MouseEvent):void {





      Why does the above script activate the "back" button for the clip on Frame 2, but not the two on Frames 3 and 4? Any ideas?


      Thank you!

        • 1. Re: Scripting mystery
          Ned Murphy Adobe Community Professional & MVP

          Are there three back buttons or just one that spans frames 2 thru 4?

          • 2. Re: Scripting mystery
            darling67 Level 1

            Hi there.


            Good question. There is ONE button that spans frames 2 to 4.


            I tried placing separate buttons on separate keyframes 2, 3, and 4 and gave each button a unique instance name... and entered separate scripts for these unique button instances on each separate frame, as well.


            I thought this might do the trick, but instead I got "duplicate definition" errors. I thought the separation on different frames would avoid that.


            Any suggestions?



            • 3. Re: Scripting mystery
              Ned Murphy Adobe Community Professional & MVP

              One button spanning the 3 frames should work, where you only have code in its keyframe (frame 2)... this is assuming the button is supposed to do the same thing in all three frames.


              When you tried the three different buttons there could have been a couple problems at work.  THe error sounds like you might have used the same function name for the event handler function.  But placing the same symbol in adjacent frames can lead to issues as well unless you have them on different layers... the latter can inherit the instance name of the prior regardless that you assign it a name manually.

              1 person found this helpful
              • 4. Re: Scripting mystery
                darling67 Level 1

                The button resides on frames 2-4, and the script now sits on a single keyframe spanning frames 2-4 (in case that hasn't been mentioned already).


                I created two new buttons for my attempted "work-around" - "created", as in duplicating the original and placing them on my "buttons" layer at frames 3 and 4. So, I had three separate buttons that performed the same function - or so they were intended to.


                Yes, I had duplicate functions because the script was the same on all three three keyframes - save for the button names.


                What I keep thinking about is how I changed the functions from "gotoAndPlay" to "gotoAndStop" for frames 3 and 4. Frame 2's function is "gotoAndPlay". That is the only variable in the whole "equation" that changed - and it changed for the better in that it actually got the buttons on frame 1 to send me to frames 3 and 4 whereas they weren't working last night. Now if only the "back" button will work across the entire movie clip!


                Thanks for following up!

                • 5. Re: Scripting mystery
                  Ned Murphy Adobe Community Professional & MVP

                  If I back up a bit on this, the problem may beclearer (to me)... If you have buttons in frame 1 to go to frame 3 or 4, but the code for back button is in frame 2, then you bypass that code and nothing gets assigned to those buttons.  What you could/should do is have the single back button spanning frames 1 thru 4 and have a command in frame 1 to turn that button invisible.  For the code that is assigned to the nav buttons in frame 1 you add code to turn the back button visible.  So the button has its code assigned at frame 1, guaranteed, and it will not be visible in frame 1 due to the command to turn it invilsible being there.  When you click a button in frame 1 it tells the back button to become visible before telling things to move down to frame 2, 3, or 4.

                  1 person found this helpful
                  • 6. Re: Scripting mystery
                    darling67 Level 1

                    Hmmmmm! Interesting. So, I can have the back button span all four frames (with its script together with the other buttons' scripts), but have it invisible (and inactive?) on frame 1? How would I create that command?


                    But, to back up... yeah, I've got a single instance of the back button on a buttons layer that spans a single, un-broken frame which begins on frame 2 and ends on frame 4. The script layer's frame mirrors the button's frame. The "mc content" layer is where the movie clips reside and are supposed to go back to frame 1 when prompted by the back button.

                    • 7. Re: Scripting mystery
                      darling67 Level 1

                      Ned, that worked!!!!


                      I placed an instance of my back button onto the "buttons" layer on frame 1 (and then had to change the function to send frame 1 to frame 2 from "gotoAndPlay" to "gotoAndStop")....


                      ... and "voíla!" - all three sub-clips in frames 2-4 go back to 1 with the "back button"!


                      Now, how do I make that instance of the back button on frame 1 "invisible"?


                      Thank you!

                      • 8. Re: Scripting mystery
                        Ned Murphy Adobe Community Professional & MVP

                        In frame 1 use...


                        guitarBack_btn.visible = false;


                        and in the event handler functions for the frame 1 menu buttons use...


                        guitarBack_btn.visible = true;


                        That way it will turn invisible anytime it enters frame 1, and when you click a menu button it will be made visible.  An invisible button cannot be interacted with (but one with alpha = 0 can).

                        • 9. Re: Scripting mystery
                          darling67 Level 1

                          Thanks so much!