4 Replies Latest reply on Jun 21, 2011 6:07 PM by Ryan Janus

    Why aren't my buttons working in Flash CS4?

    Ryan Janus

      I'm new to Actionscript 3, and it doesn't seem to work at all the way actionscript 2 used to. I have a very simple slash page I'm designing for a friend, which includes a "click here to enter" button. The button never works. In fact, after the animation is done, it always says:


      "TypeError: Error #1009: Cannot access a property or method of a null object reference.  at murphysplash_fla::MainTimeline/frame60()"


      The behaviors, like rollovers, work fine, but the button doesn't do anything when I click it during a test/preview. Here is my actionscript:



      click_to_enter_btn.addEventListener (MouseEvent.CLICK, goHome);

      function goHome (event:MouseEvent):void {

      navigateToURL (new URLRequest("http://www.seanmurphysaxophone.com/index.html"), "_blank");



      The "stop" is so that the animation doesn't keep running over and over. (Also note that "seanmurphysaxophone.com is not yet built, but I should still be getting the browser to at least try and go somewhere.) This seems like something which should be simple, and I'm just not seeing the problem. Anyone have any thoughts?



      Ryan Janus


        • 1. Re: Why aren't my buttons working in Flash CS4?
          robdillon Most Valuable Participant

          That error usually indicates that the button instance on the stage, at least in the frame where you are using it, is not named. Make sure that the button instance is named "click_to_enter_btn" in the frame that shows at that stop.

          1 person found this helpful
          • 2. Re: Why aren't my buttons working in Flash CS4?
            relaxatraja Level 5

            Check whether you named the instance with the name click_to_enter_btn. Select the button on the stage and check for the instance name in the property window , have the reference below in screenshot.



            1 person found this helpful
            • 3. Re: Why aren't my buttons working in Flash CS4?
              Ned Murphy Adobe Community Professional & MVP

              The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
              - is not in the display list
              - doesn't have an instance name (or the instance name is mispelled)
              - does not exist in the frame where that code is trying to talk to it
              - is animated into place but is not assigned instance names in every keyframe for it
              - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).


              Because you mentioned an animation in your description, I'm suspiscious that it might have to do with the fourth item listed.

              If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

              • 4. Re: Why aren't my buttons working in Flash CS4?
                Ryan Janus Level 1

                @ Rob and relaxatraja: That did make it crash at first, but I double-triple-checked and fixed it, so that was no longer the issue.


                @ Ned: I think you're answer #4 was mostly right. After much more trial and error - and cursing - I decided to move that same bit of AS code to the first frame of my "actions" layer. For some reason, that was all I needed to fix it, and it works fine now. Thank you all for responding so quickly! I don't do this professionally, and I appreciate your concise answers to my novice/rookie questions.