11 Replies Latest reply on Aug 31, 2010 4:18 AM by toolmania1

    onRelease error

    toolmania1 Level 1

      I am getting an error when I run this code:

       

      button.onRelease()

      {

      gotoAndPlay("home");

      }

       

      Do I need to do something before calling that onRelease?

       

      Everything elses looks good unless I am missing something.


      The movie will compile, but the buttons do not work.  They will not go to the frame with the label "home" that I set up.

        • 1. Re: onRelease error
          kglad Adobe Community Professional & MVP

          try:

           


           

          button.onRelease=function()

          {

          gotoAndPlay("home");

          }

           


          1 person found this helpful
          • 2. Re: onRelease error
            toolmania1 Level 1

            Sorry, I was not accurate enough in my explanation.  That is what I have.  I am not in front of the code right now, I posted that from memory.

             

            button.onRelease=function()

            {

            gotoAndPlay("home");

            }

            • 3. Re: onRelease error
              kglad Adobe Community Professional & MVP

              when you get back to your file, retest and copy and paste the error message and copy and paste the relevant code.

              1 person found this helpful
              • 4. Re: onRelease error
                toolmania1 Level 1

                Ok.  I will get to it later tonight.  Thanks.  I will try to attach a screen shot of the error as well.

                • 5. Re: onRelease error
                  toolmania1 Level 1

                  There is not much point to a screen shot, since this is the error:

                   

                  "ReferenceError: Error #1056: Cannot create property onRelease on flash.display.SimpleButton.
                      at mainPage3_fla::MainTimeline/mainPage3_fla::frame2()"

                   

                   

                  Relevant code:

                   

                  mc_buttonMenu.btn_home.onRelease = function()
                  {
                       mc_allPages.gotoAndPlay("2");
                  }

                   

                  mc_buttonMenu.btn_contactUs.onRelease = function()
                  {
                       mc_allPages.gotoAndPlay("11");
                  }

                  • 6. Re: onRelease error
                    kglad Adobe Community Professional & MVP

                    that code should be attached to a frame, not an object.

                     

                    also, make sure you're publishing for as2, not as3.

                    1 person found this helpful
                    • 7. Re: onRelease error
                      toolmania1 Level 1

                      How would I attach it to a frame instead of an object?

                       

                      I have it in its own layer on the first frame.  That is not attaching it to a frame?

                      • 8. Re: onRelease error
                        skarthiks Level 2

                        The thing is that, when you publish a swf as AS3 you cannot attach actionscript on objects (in this case the button).

                        When I say attaching the actionscript to a button it means, you select the button (using a selection tool) on the stage and then type the actionscript code.

                         

                        all you would have to do is, click on the stage (white area behind your objects) and then add the code for the button.

                         

                        Also, in AS3 the code for adding a click event is as below,

                         

                        mc_buttonMenu.btn_contactUs.addEventHandler(MouseEvent.CLICK, contactusHandler);

                         

                        function contactusHandler(e:MouseEvent){

                        gotoAndPlay("11");

                        }

                         

                        If you do not want to write the code in AS3, change the publish settings to AS2,

                         

                        Press Cntrl+Shift+F12  to choose File Menu -> Publish Settings. Goto the "Flash" tab and change the "Script" to AS2. and then publish the file, you will not get the error.

                         

                        publish.JPG

                         

                        Thanks

                        Karthik

                        • 9. Re: onRelease error
                          kglad Adobe Community Professional & MVP

                          no, you have the code attached to an object.  cut that code, click a frame and paste the code into the actions panel.

                          • 10. Re: onRelease error
                            toolmania1 Level 1

                            No, I want to learn AS 3.  It has been suggested a few times to learn it.

                             

                            Well, also, for the code I have, I did not change it to AS2 in the settings.  But, that is ok.  I want to do AS3 anyways.  So, I will try the below later tonight.

                             

                            Thanks!

                            • 11. Re: onRelease error
                              toolmania1 Level 1

                              Sorry, I wanted to mark yours as correct answer also but the option is gone.  I must have marked it helpful the other day.