9 Replies Latest reply on Oct 12, 2010 7:18 AM by pawmunkey

    Button error, 1061 error,

    pawmunkey Level 1

      I am new to ActionScript 3. I created a simple button that I imported into the stage and I named  and saved it as Microwave_btn
      and I wrote a simple script for it that says:

       

      stop ();

      import flash.display.*;
      import flash.events.*;

      Microwave_btn.addEventListener(MouseEvent.CLICK, Trace);
      function Trace (event:MouseEvent): void {
      trace("Microwave!");
      }

      The properties for the Microwave_btn has the
      class labeled as: Microwave_btn
      and the
      Base class as: flash.display.SimpleButton

      When I test the movie I get this error:
      1061: Call to a possibly undefined method addEventListener through a reference with static type Class.

        • 1. Re: Button error, 1061 error,
          kglad Adobe Community Professional & MVP

          try:

           



          import flash.display.*;
          import flash.events.*;

           

          var btn:Microwave_btn=new Microwave_btn();

          addChild(btn);

           

          btn.addEventListener(MouseEvent.CLICK, Trace);
          function Trace (event:MouseEvent): void {
          trace("Microwave!");
          }

          • 2. Re: Button error, 1061 error,
            pawmunkey Level 1

            Thank you so much. What I don't  understand is that I have two buttons on my screen now and the button  that works is located on the top left corner of my screen. My original  button which is located on top of the background image (microwave) does  not invoke the Microwave Trace function.

             

            How do I get that  to work and remove the Microwave_btn image from the top left corner of  my screen and get original button to work?

            • 3. Re: Button error, 1061 error,
              pawmunkey Level 1

              Thank you so much. What I don't

              understand is that I have two buttons on my screen now and the button

              that works is located on the top left corner of my screen. My original

              button which is located on top of the background image (microwave) does

              not invoke the Microwave Trace function. How do I get that to work and remove the Microwave_btn image from the top left corner of my screen and get original button to work?

               

              Date: Mon, 11 Oct 2010 11:52:31 -0600

              From: forums@adobe.com

              To: edaddy@hotmail.com

              Subject: Button error, 1061 error,

               

              try:

               

               

               

              import flash.display.*;

              import flash.events.*;

               

              var btn:Microwave_btn=new Microwave_btn();

              addChild(btn);

               

              btn.addEventListener(MouseEvent.CLICK, Trace);

              function Trace (event:MouseEvent): void {

              trace("Microwave!");

              }

               

               

              >

              • 4. Re: Button error, 1061 error,
                kglad Adobe Community Professional & MVP

                the code i suggested created that top-left button.  if you want to use the one on-stage, click it (to select it) and in the properties panel assign an instance name (eg, btn).   you can then use:

                 

                 

                btn.addEventListener(MouseEvent.CLICK, Trace);


                function Trace (event:MouseEvent): void {
                trace("Microwave!");
                }

                • 5. Re: Button error, 1061 error,
                  pawmunkey Level 1

                  I have only one button on the stage which is the Micowave_btn. I also named the instance name for the button Microwave_btn.

                   

                  When I try compiling the movie I get a new error message that says:

                  1046: Type was not found or was not a compile-time constant: Microwave_btn.

                  • 6. Re: Button error, 1061 error,
                    kglad Adobe Community Professional & MVP

                    a class name can't be the same as an instance name.  fix that and use the above code i suggested.

                    • 7. Re: Button error, 1061 error,
                      pawmunkey Level 1

                      Ok!  I reposted my question with screen shots at

                      http://forums.adobe.com/message/3200329#3200329

                       

                      I changed the Microwave_btn instance name to microwave_mc and I still get two images of the Microwave_btn on the stage and the one at the top left corner works.

                       

                      I would like tpl create 5 buttons total:

                      Dishwash_btn        dishwash_mc (instance name)

                      Faucet_btn             faucet_mc (instance name)

                      Microwave_btn       microwave_mc (instance name)

                      Refrig_btn              refrigwash_mc (instance name)

                      Stove_btn               stove_mc (instance name)

                       

                      If you read my reposted question you should be able to have a better understand of what I want to accomplish.

                      • 8. Re: Button error, 1061 error,
                        kglad Adobe Community Professional & MVP

                        i assume this thread is closed and i see your other thread has a responder.  good luck!

                        • 9. Re: Button error, 1061 error,
                          pawmunkey Level 1

                          Thanks for your assistance. I was able to figure most of it out.

                           

                          Date: Mon, 11 Oct 2010 19:13:19 -0600

                          From: forums@adobe.com

                          To: edaddy@hotmail.com

                          Subject: Button error, 1061 error,

                           

                          i assume this thread is closed and i see your other thread has a responder.  good luck!

                          >