8 Replies Latest reply on Mar 2, 2010 1:18 PM by Jane at SFSU

    Mystery button action bug w/AS 2.0 in CS4

    Jane at SFSU

      I teach an intro interactive media class and have run into this with CS3 and CS4:

      SIMPLE button actions won't work on SOME buttons, nothing fixes it.

       

      on (press) {

      gotoAndStop("screen1");

      }

       

      I start out with timeline navigation forward and backward, and this is where SOME of the buttons won't work.  No error message comes up.  I have the students use the actions menu, type it in from scratch, copy from another action, delete the action and restart flash, delete the button and start over.  Nothing works.

       

      Why aren't I using AS 3.0?  Because represents a much steeper learning curve for visual communication design students and learning the basics of simple scripting provides a good experience in procedural thinking and how it all works.

       

      I am assuming that as long as Flash actually allows you to create AS 2.0 documents that it should work, right???

       

      Thanks - Jane

        • 1. Re: Mystery button action bug w/AS 2.0 in CS4
          Ned Murphy Adobe Community Professional & MVP

          The code should work properly but your implementation may be the source of the problem.  You describe having timeline navigation moving forward and backward which makes me think you might have objects in adjacent frames and things like that.  Such a scenario can cause subsequent objects to inherit precedent objects' characteristics.

           

          I don't wanna throw a fly in the soup, but if you are teaching AS2 then you should at least teach best practices, and placing code on objects using on(anything) is not good practice.  Assigning instance names and using timeline code is the better way to go, and prepares students for moving on to AS3 and OO programming in general.

          • 2. Re: Mystery button action bug w/AS 2.0 in CS4
            Harry Kunz Level 4

            I assume you want to gotoAndPlay on the main timeline. That means the code is incorrect. The gotoAndStop within the on(press) handler is the same as this.gotoAndStop where this refers to the target button and not the main time line object. Use _parent.gotoAndStop() if the button is directly a child of the main timeline object or _root.gotoAndStop() to directly target the main timeline object. But as Ned mentioned, it is bad practice to place code elsewhere other than the main timeline where it is centralized and easier to maintain. Centralizing code is a good preparation for OOP.

             

            Use in main timeline frame 1:

             

            ButtonInstanceName.onPress = function() {

               this.gotoAndStop(framenumber);

            }

            • 3. Re: Mystery button action bug w/AS 2.0 in CS4
              Ned Murphy Adobe Community Professional & MVP

              I have to disagree with the point of gotoAndStop telling the button to move along its timeline.  Any time I have used code attached to a button it is targeting the timeline the button exists in, not the button's timeline.  So using it as originally presented should move to the correct frame.  I am just not sure that the setup itself isn't the problem.

               

              Still the timeline approach removes any confusion in the matter as far as which timeline is being addressed.

              • 4. Re: Mystery button action bug w/AS 2.0 in CS4
                Harry Kunz Level 4

                That's weird. I was able to reproduce a weird bug when i was at the office using CS4. I was able to target the movieclip's timeline with the this.gotoAndStop() called within the on(press) handler. So i had to use _parent or _root to target the main time line. Maybe that was a bug? I tried it again at home with CS3 but "this" now refers to the timeline. Have you tried it on CS4?

                • 5. Re: Mystery button action bug w/AS 2.0 in CS4
                  Ned Murphy Adobe Community Professional & MVP

                  I avoided CS4... twas the bugs that kept me away.

                  • 6. Re: Mystery button action bug w/AS 2.0 in CS4
                    Jane at SFSU Level 1

                    YES, that's it!!!  I should have thought of making the direction of the action more specific....  It's easy to get stuck in a "should work" state of mind...>;O)

                     

                    Mr. Kunz - THANK YOU SO MUCH for confirming this wierd and inconsistent bug.  I've had student projects where ONE button had this problem amongst a dozen others that worked fine without "_root." in front of the action.  In this most recent case, all the buttons navigating forward in a linear fashion worked but none of the buttons navigating backward along the sequence of screens worked.  Wierd, huh!?!

                     

                    I have now communicated the solution to my students and explained the "hierarchy of timelines" issue and Dot Syntax one week early.  We were going to get into nested movieclips and absolute vs relative action targetting next week.  Now, everyone will have a solidly working project for moving into that complexity.

                     

                    ADOBE:  THIS IS A BUG!!!

                     

                    Thanks again - Jane Veeder, DAI 327

                    http://online.sfsu.edu/~jkv4edu

                    • 7. Re: Mystery button action bug w/AS 2.0 in CS4
                      Harry Kunz Level 4

                      Okay. No problem. By the way i was able to reproduce the problem your student must have encountered. I'm not sure if there is a difference having both CS3 and CS4 installed. I did a verification test with both CS3 & CS4 by creating a button and movieclip on stage. Both had the code on(press) {trace(this;}. The code in the movieclip traces itself as target while the code on the button traces the time line's object as target. But if you attempt to change the symbol in the library from a movieclip to button or vice-versa, the target object traced remains the same (which might be a bug?). So most likely your student must have changed the class of the object in library from a movieclip to button that's why it still targeted itself.

                      • 8. Re: Mystery button action bug w/AS 2.0 in CS4
                        Jane at SFSU Level 1

                        AH!!!  I understand and that makes sense as a likelihood.  I will ask the student.  She does not have both Cs3 and 4 installed on her laptop but sometimes students get software from obscure sources so that might also figure.

                         

                        Thanks SO much for pointing out the workaround - I like how the thinking works.  I tell my students that competency is not based on being lucky enough to have everything work right the first time out.  You must HAVE the problems in order to learn how to avoid or solve them.

                         

                        Jane

                        Jane Veeder, Professor, Visual Communication Design

                        Department of Design & Industry

                        San Francisco State University, 1600 Holloway Avenue, SF, CA 94132

                        Email:  jveeder@sfsu.edu

                        Teaching Hub:  http://online.sfsu.edu/~jkv4edu

                        Bio Site:  http://online.sfsu.edu/~jkveeder