19 Replies Latest reply: Feb 15, 2011 6:38 PM by hawkmankt RSS

    1120:Access of undefined property error

    csgdon Community Member

      I'll try and be clear about my problem. I'm working on a site and have a MovieClip, named "form" on the main timeline that I want to play when a button is clicked. I keep getting this error and it's driving me crazy, I'm obiously missing something. The button instance name is "sub_btn". Below is my code , it's the subscription button code, but not quite sure what's up, I'm not an actionscript guru but am gaining a small understanding of it. If anyone can help that be awesome. Also I have a close button on that movie clip is there a simple close script I can attach. Thanks again.

       

      Dt

       

       

       

      stop();
      import flash.events.MouseEvent;
      var getHCSG:URLRequest = new URLRequest("http://www.houstonceliacs.org");
      var twitter:URLRequest = new URLRequest("http://www.dggrafix.com/glutenfree/twitter.html");

       


      // --- Page Button navigation --- \\

       

      home_btn.addEventListener(MouseEvent.CLICK, hClick);
      glutenfree_btn.addEventListener(MouseEvent.CLICK, gClick);
      menu_btn.addEventListener(MouseEvent.CLICK, mClick);
      restaurant_btn.addEventListener(MouseEvent.CLICK, rClick);
      contact_btn.addEventListener(MouseEvent.CLICK, cClick);

       

      function hClick(event:MouseEvent):void{
          gotoAndPlay("home");
      }
      function gClick(event:MouseEvent):void{
          gotoAndPlay("glutenfree");
      }
      function mClick(event:MouseEvent):void{
          gotoAndPlay("menu");
      }
      function rClick(event:MouseEvent):void{
          gotoAndPlay("restaurants");
      }
      function cClick(event:MouseEvent):void{
          gotoAndPlay("contact");
      }

       

      // -- Get URL Button -- \\

       

      supportgrp_btn.addEventListener(MouseEvent.CLICK, hcClick);

       

      function hcClick(event:MouseEvent):void{
          navigateToURL(getHCSG);
      }
      twitter_btn.addEventListener(MouseEvent.CLICK, tClick);

       

      function tClick(event:MouseEvent):void{
          navigateToURL(twitter);
      }

       

      // --- Subcribtion Button navigation --- \\

       

      sub_btn.addEventListener(MouseEvent.CLICK, clClick);

       

      function clClick(event:MouseEvent):void{
          form.play();
      }

        • 1. Re: 1120:Access of undefined property error
          Ned Murphy MVP

          Can you provide the complete error message?

          • 2. Re: 1120:Access of undefined property error
            csgdon Community Member

            Thanks for responding, the full error message is:

             

            Symbol 'Main', Layer 'actions', Frame 1, Line 46  1120:Acess of undefined property sub_btn.

             

             

            I think I checked that the instance name is correct but just can't get it.

             

            Dt

            • 3. Re: 1120:Access of undefined property error
              csgdon Community Member

              Thanks, Ned for responding the complete error message which I posted 

              back on the forum is.

               

              Symbol 'Main', Layer 'actions', Frame 1, Line 46   1120: Access of 

              undefined property sub_btn.

               

              Hope you can help.

               

              Dt

              • 4. Re: 1120:Access of undefined property error
                kglad MVP

                in the frame that causes that error to appear, if you click on an empty part of the stage and then click on sub_btn, do you see exactly sub_btn in the properties panel?

                 

                if not, that's the problem.  if so, post a link to your fla or upload it after changing its extension.

                • 5. Re: 1120:Access of undefined property error
                  Ned Murphy MVP

                  The code for sub_btn looks okay, so it'll be a matter of going thru the usual suspects.

                   

                  The primary suspect is always the instance name.  So if you click on the button on the stage to select it, the instance name in the properties panel needs to be the same as the one you use in the code.  If there's any doubt, actually change the name in both places just to insure it's the same.

                   

                  Another suspect regards the location of code versus the location of the object.  Is sub_btn present in frame 1?

                   

                  Along a similar line, targeting can sometimes be the issue... is sub_btn a standalone object, not contained in some other object?

                   

                  If none of these lead to a resolution, can you make the fla file available for a look-see (I'm limited to Flash CS3 and below though).

                  • 6. Re: 1120:Access of undefined property error
                    csgdon Community Member

                    Thanks for replying,

                     

                    yes, sub_btn is the instance name I used for the button. So I'm 

                    assuming that is what you were speaking on.  I will post the FLA file 

                    to take a look at. Thanks.

                     

                     

                    Dt

                    • 7. Re: 1120:Access of undefined property error
                      csgdon Community Member

                      Ned, thanks for replying again. I don't think it's the instance name, 

                      that was the first thing I checked. They are both the same. It maybe 

                      what you said about where it's located. The form that I want it to 

                      open is on the main timeline but the button itself is inside another 

                      movieclip on the timeline.

                       

                      I'm going to try and post the FLA file so you can have a look, Thanks.

                       

                      Dt

                      • 8. Re: 1120:Access of undefined property error
                        csgdon Community Member

                        Can you send me an email address, I wanted to post my FLA file for you to take a look but the max size is 5 MB and my file zipped is over that so it's not going to post. Please send me an email that i can send it to you directly. Thanks

                         

                        Dt

                        • 9. Re: 1120:Access of undefined property error
                          Ned Murphy MVP

                          I suggest you strip the file down of unrelated content so that you can post it somewhere.  I don't hand out my email for having files sent to me--making it available to the general public is to your benefit.  I may not be around to look at it, but someone else may.

                          • 10. Re: 1120:Access of undefined property error
                            csgdon Community Member

                            Thanks, I will do that.

                             

                            Dt

                            • 11. Re: 1120:Access of undefined property error
                              csgdon Community Member

                              I'm going to post my native FLA file in a little bit. Ned, I noticed you mentioned it may be the location of the code, I have the code on the main timeline where the movieclip I want to open i, the button sub_btn is actually inside another movieclip on the maintimeline. Should the code be in the same movieclip as the button. Which may go along with the other thing you mention, targeting. Do I need to make reference of the parent of the button, or the movieclip the button is housed in?

                               

                              Thanks.

                               

                              Don

                              • 12. Re: 1120:Access of undefined property error
                                Ned Murphy MVP

                                Yep... targeting may be the problem.  You don't necessarily need to have the code in the movieclip that the button is in.  You can target the code for the button from the maintimeline if you preclude it with the instance name of the movieclip it's sitting in...

                                 

                                movieName.sub_btn.addEventListener....

                                • 13. Re: 1120:Access of undefined property error
                                  csgdon Community Member

                                  Ned, I think that may be the case, I didn't preclude it with the movie clip it's in. I'm going to try that and I will let you know.

                                   

                                  Dt

                                  • 14. Re: 1120:Access of undefined property error
                                    csgdon Community Member

                                    Hey Ned,

                                     

                                    You're the man!! That bit of advice worked liked a charm, it was the targeting. It really cleared up a lot of things for me too, now I know. Once again thanks for your help.

                                     

                                    Don

                                    • 15. Re: 1120:Access of undefined property error
                                      Ned Murphy MVP

                                      You're welcome

                                      • 16. Re: 1120:Access of undefined property error
                                        shademup

                                        Hi,

                                         

                                        I also have almost similar problem to this.  Mine is going to a frame "reservationpage".  I set a button on  frame 3 in "treatmentspage" that should call on "reservationpage" in frame 8.

                                         

                                        I have been using this code:

                                         

                                        myreserve_btn.addEventListener(MouseEvent.CLICK, onReservClick);

                                         

                                        function onReservClick(evt:MouseEvent):void {
                                            gotoAndStop("reservation page");
                                           
                                            myreserve_btn.removeEventListener(MouseEvent.CLICK, onReservClick);
                                        }

                                         

                                        but keep getting:

                                         

                                        TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                            at SpaLuvicebestmassageoptionintown_fla::MainTimeline/frame3()
                                            at flash.display::Sprite/constructChildren()
                                            at flash.display::Sprite()
                                            at flash.display::MovieClip()
                                            at SpaLuvicebestmassageoptionintown_fla::innnerbody_25()
                                            at flash.display::Sprite/constructChildren()
                                            at flash.display::Sprite()
                                            at flash.display::MovieClip()
                                            at flash.display::MovieClip/gotoAndStop()
                                            at SpaLuvicebestmassageoptionintown_fla::MainTimeline/bodymassagebtn_clicked()

                                         

                                        can I get help on this please?

                                        • 17. Re: 1120:Access of undefined property error
                                          Macmur Community Member

                                          I'm having a similar problem. I have in my project four flv video inside of a movieclip. I have a custom play/pause buttons for each of the four vids (well one generic playBtn & pauseBtn, instance names different for each vid on the generic play/pause buttons) The actionscript I have to play/pause video is this: 

                                                    fishyPauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);

                                                    fishyPlayBtn.addEventListener(MouseEvent.CLICK, playHandler);

                                           

                                                    function pauseHandler(e:MouseEvent):void{

                                                    fishyVid.pause();

                                           

                                                    }

                                                    function playHandler(e:MouseEvent):void{

                                                    fishyVid.play();

                                                    }

                                           

                                          This works fine & it stops & plays the video when there are pressed. But when I use the same script on other video it doesn't work I get this:

                                          Picture 1.png

                                          function pauseHandler(e:MouseEvent):void{  when I double click on the code error in the compiler error panel tab this is the line of code thats highlighted

                                          function playHandler(e:MouseEvent):void{  when I double click on the code error in the compiler error panel tab this is the line of code thats highlighted

                                           

                                          I then renamed the pauseHandler & playHandler to pauseHanddler_B, playHanddler_B, this stops the above error but it doesn't pause or play another

                                          video, I get this message in the output panel:

                                          Picture 2.png

                                          I've tired scripting all the buttons to play & pause the video's in one script like so:

                                           

                                           

                                          fishyPauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);

                                          fishyPlayBtn.addEventListener(MouseEvent.CLICK, playHandler);

                                          mashedPauseBtn.addEventListener(MouseEvent.CLICK, playHandler)

                                          mashedPlayBtn.addEventListener(MouseEvent.CLICK, playHandler)

                                           

                                          function pauseHandler(e:MouseEvent):void{

                                          fishyVid.pause();

                                          mashVid.pause();

                                          }

                                          function playHandler(e:MouseEvent):void{

                                          fishyVid.play();

                                          mashVid.play();

                                          }

                                          But yet again I get this message in the output panel:
                                          Picture 3.png

                                          I've tired putting the script at each section in the timeline where the video is playing and it doesn't work it will pause & play one of the videos. Can anybody bring me out of the darkness, please I'm going mad by this! Thanks

                                          • 18. Re: 1120:Access of undefined property error
                                            hawkmankt

                                            Ned, this totally saved my butt on a school project where I had my buttons moving in a movie clip file.

                                             

                                            Thanks bro!

                                            • 19. Re: 1120:Access of undefined property error
                                              Ned Murphy MVP

                                              You're welcome