8 Replies Latest reply on Aug 3, 2010 10:30 AM by nikolaig

    What is the proper way to design movie clip buttons

    nikolaig Level 1

      Is there a possible issue in the way the button is made not coded?

       

      I am using Flash CS4. My buttons seem not to work. I do not think issue is in the action script (I am scripting in 3.0).

      Here is the way I make the button. I add a movie clip on the stage on the over state ( so if you were to double click on that movie clip a new time line would open), at the end of that movie clip there is a simple stop(); code on its own line. I do not add extra frame on the over state.

      Then I assign the code to the button and of course cross reference its name in the properties and everything is matching up. Just in case here is my code:

       

      floralyte_btn.addEventListener(MouseEvent.CLICK, onClickFloraLytePopUp);

       

      function onClickFloraLytePopUp(event:MouseEvent) :void {

      gotoAndStop("61");

       

      }

      All of my buttons work fine through the Up, Over, Down, HIt stages without the problem.
      The functionality works fussy, some of them I have to click twice to go to the specified frame with the UILoader, some do not work at all and some work.
      I double checked and all of them seem to be done identical.

        • 1. Re: What is the proper way to design movie clip buttons
          Ned Murphy Adobe Community Professional & MVP

          First, are you talking about movieclips as buttons or button symbols?  Movieclip symbols do not have the Up Over Down Hit frames, but button symbols do.

           

          For the code you show, if 61 is a frame number, it should not have quotes.  And the code itself should be on the timeline that contains the button, not within the button (not sure where you have it by your description).

          1 person found this helpful
          • 2. Re: What is the proper way to design movie clip buttons
            nikolaig Level 1

            I am talking about the button symbols. I insert a movie clip symbol on the over stage, so if you were to double click on the symbol in the Over frame a movie clip time line would open up.

            The code is on the time line above the whole animation sequence on its own layer, not within the button. The only code within the button is "stop();" assigned at the end of the movie clip of the over stage.

            • 3. Re: What is the proper way to design movie clip buttons
              Ned Murphy Adobe Community Professional & MVP

              Aside from changing the frame numbers to be numbers and not strings... You mentioned the code is on a timeline above the whole animation sequence.  If you are animating the buttons, then you need to be sure to assign their instance names for each keyframe.  And you also need to assign the button event listener code at any keyframes where the buttons should function.  Each new keyframe creates a new instance of an object, so any code assigned to it in an earlier frame no longer applies.

               

              If you happen to be getting error messages, copy/paste them in your posting.

              1 person found this helpful
              • 4. Re: What is the proper way to design movie clip buttons
                nikolaig Level 1

                I removed the quotes from "61" and now it reads 61. It works the same as

                before with the same error message:

                 

                TypeError: Error #1009: Cannot access a property or method of a null object

                reference.

                at

                acolyte2_fla::MainTimeline/frame11()[acolyte2_fla.MainTimeline::frame11:14]

                at flash.display::MovieClip/gotoAndStop()

                at

                acolyte2_fla::MainTimeline/onClick_products()[acolyte2_fla.MainTimeline::frame1:13]

                 

                Here are the referenced lines from frame 11, line 14:

                 

                floralyte_btn.addEventListener(MouseEvent.CLICK, onClickFloraLytePopUp);

                 

                here is the rest of the code after the line 14:

                floralyte_btn.addEventListener(MouseEvent.CLICK, onClickFloraLytePopUp);

                 

                function onClickFloraLytePopUp(event:MouseEvent) :void {

                gotoAndStop(61);

                }

                 

                 

                Note, that this error message is in the OUTPUT tag and the function still

                works despite the error message.

                 

                Here is the code from 1:13

                gotoAndStop("products");

                 

                and the rest of the code above it:

                 

                products_btn.addEventListener(MouseEvent.CLICK, onClick_products);

                 

                function onClick_products(event:MouseEvent) :void {

                gotoAndStop("products");

                }

                • 5. Re: What is the proper way to design movie clip buttons
                  Ned Murphy Adobe Community Professional & MVP

                  At frame 11, the floralyte_btn apparently does not exist in the eyes of the code trying to target it... you can confirm this by using trace(floralyte_btn); just before line 14.  There is most likely some issue with naming it.  Check if my earlier response might be the problem.  Otherwise, it could be a mispelling of the instance name or none asigned at all.

                  1 person found this helpful
                  • 6. Re: What is the proper way to design movie clip buttons
                    nikolaig Level 1

                    I typed the code trace(floralyte_btn); on the line 13 and tested the movie

                    but nothing happened. Please let me know in more details how to use this

                    trace functions.

                    I copied the name floralyte_btn from the properties field (if it is there it

                    confirms that instance name is assigned) into coding window, so there could

                    not be a mistake in misspelling.

                     

                    Any possible issue with the way the buttons are made or if they are working

                    fine on all the stages and do what I wanted them to do then there could be

                    no issue?

                    • 7. Re: What is the proper way to design movie clip buttons
                      Ned Murphy Adobe Community Professional & MVP

                      The trace function is basically a design aid used primarily for testing/troubleshooting code.  It is a very handy tool to know how to use.  All it does is cause whatever you tell it to display to show up in the Output panel when you run the file and the code executes.  So you can use it to determine the status/value of variables at different stages of processing, to see if/when code stps processing when a problem arises, and such as wthe usage I mentioned for you to try, to see if trace(floralyte_btn); ended up producing a null or undefined output (doesn't exist as the code sees it) as opposed to identifying that it is an object.

                       

                      If you are continuing to get the 1009 error, I can pretty much assure you it is doing so because the error exists.  You just have to figure out what might be the source of the failure to communicate.  Here's a summary of the primary possible causes for a 1009 error...

                       

                      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).

                      1 person found this helpful
                      • 8. Re: What is the proper way to design movie clip buttons
                        nikolaig Level 1

                        Thanks for the feedback, I'll be looking into the issue trying to figure it

                        out.