9 Replies Latest reply on Jun 29, 2011 2:27 PM by element115

    CS4 AS Error 1120 - Access of Undefined Property.

    pat-garnham87

      I feel like a real noob and need help!

       

      I am new to Flash but have been able to fumble my way through action scripts with a bit of help from old forum posts.

       

      What i have done so far: developed a little map with buttons to act as navigation for webpage, all worked fine with each button linking to a seperate page.

       

      What i need to do: i have new content which needs to be added, therefore i need another button. all went fine to insert the new button, name it, new layer etc.

      I have copied the exact same code for this button to work (just chaning the name) from the 7 other working buttons in the swf.

       

      The error i get is 1120: Access of undefined property wind. for the last line in below code:

       

      Button that doesn't work:

       

      import flash.events.MouseEvent;

      function gotoWIND(event:MouseEvent):void {
         var windURL=new URLRequest("http://www.hydro.com.au/node/462");
         navigateToURL(windURL,"_self");
      }

      wind.addEventListener(MouseEvent.CLICK,gotoWIND);

       

       

      Button(s) that do work:

       

      import flash.events.MouseEvent;

      function gotoKING(event:MouseEvent):void
      {
         var kingURL:URLRequest = new URLRequest("http://www.hydro.com.au/node/405/");
         navigateToURL(kingURL,"_self");
      }

      king.addEventListener(MouseEvent.CLICK,gotoKING);

       

       

      i have done a bit of research and have found that this means i haven't named the button right, but i have double and triple checked, redone with a simpler word (wind) but still no joy. And the only other response i could find on this forum was about multiple frames - but as this is a 'static' navigation panel it only has one frame for each layer.

       

      please help!

        • 1. Re: CS4 AS Error 1120 - Access of Undefined Property.
          kglad Adobe Community Professional & MVP

          the only sure way (that i know of) to fix that issue is to clear all keyframes that contain the problematic object (eg, king) except the initial frame that contains king.  make sure king is the object's name in that first (and, so far, only, keyframe).  test your code.  it should work unless you misnamed something or failed to clear all keyframes containing king.

           

          then add keyframes as needed (being careful to NOT remove king from any keyframes).  retest.  everything should work.  you can then (usually) remove king from keyframes where you want to remove it as long as you're not trying to reference it in a frame where it doesn't exist.

          1 person found this helpful
          • 2. Re: CS4 AS Error 1120 - Access of Undefined Property.
            pat-garnham87 Level 1

            Thanks for the speedy reply

            I probably did not expalin it properly in my rushed typing, so just to confirm a couple of things:

             

            - the problematic button is 'wind', king is still working.

            - there are multiple layers all with only one frame.

             

            so from what you have said there is something which is misnamed.

             

            the only things i have name for this action are the button as 'wind' and in the actionscript. is there naming anywhere else which i need to check?

             

            thanks again,

            pat

            • 3. Re: CS4 AS Error 1120 - Access of Undefined Property.
              kglad Adobe Community Professional & MVP

              is wind in one keyframe in your timeline?  if not, re-read my message substituting wind for king.

              1 person found this helpful
              • 4. Re: CS4 AS Error 1120 - Access of Undefined Property.
                pat-garnham87 Level 1

                Hi,

                 

                yes wind is in one keyframe only.

                 

                cheers,

                pat

                • 5. Re: CS4 AS Error 1120 - Access of Undefined Property.
                  kglad Adobe Community Professional & MVP

                  in the frame that contains your code, use the following, click wind and copy and paste your output panel text.

                   

                  import flash.events.MouseEvent;

                  trace(wind);

                   

                  function gotoWIND(event:MouseEvent):void {

                  trace("**",event.currentTarget.name);
                     var windURL=new URLRequest("http://www.hydro.com.au/node/462");
                     navigateToURL(windURL,"_self");
                  }

                  wind.addEventListener(MouseEvent.CLICK,gotoWIND);

                  • 6. Re: CS4 AS Error 1120 - Access of Undefined Property.
                    pat-garnham87 Level 1

                    thanks - that worked, all links working now!

                    • 8. Re: CS4 AS Error 1120 - Access of Undefined Property.
                      element115

                      I have the same error, under slightly different conditions in CS5. I have an external actionscript file that I want to put all of my functions in, and so I can have global variables. It is called (root folder)/comm/LaserTypingDevelop.as and contains this (edited) code:

                      ******************************

                      package comm
                      {
                          public class LaserTyping extends movieClip
                          {
                              public var gCurrentLetter:String = "";
                              public var gCurrentKey:String = "";

                       

                              public function keyDownHandler(e:KeyboardEvent):void
                              { ...function code... }

                       

                              public function keyUpHandler(e2:KeyboardEvent):void
                              { ...function code...}

                          }


                      }

                      ***********************************

                      The .fla source file contains this in frame 1:

                       

                      1 import flash.events.KeyboardEvent;
                      2 import flash.text.TextField;
                      3 import comm.LaserTypingDevelop;

                      4

                      5 stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
                      6 stage.addEventListener(KeyboardEvent.KEY_UP,keyUpHandler);

                       

                       

                      The error I'm getting is

                      Scene 1, Layer 'code', Frame 1, Line 5    1120: Access of undefined property keyDownHandler.
                      Scene 1, Layer 'code', Frame 1, Line 6    1120: Access of undefined property keyUpHandler.

                       

                       

                      Am I needing to import something else? keyDownHandler is a function, not a property.

                       

                      Thanks

                      Michael

                      • 9. Re: CS4 AS Error 1120 - Access of Undefined Property.
                        element115 Level 1

                        So, what I've learned today, is that the method called from a class has to include the class name in the call.

                        In the .fla source file:

                        old

                        5 stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);

                        new

                        5 stage.addEventListener(KeyboardEvent.KEY_DOWN,this.LaserTyping.keyDownHandler);

                         

                        Now there are no errors at compile. HOWEVER at run time, the output window is populated with:

                        TypeError: Error #1010: A term is undefined and has no properties.
                            at LaserTyping/frame1()

                         

                        LaserTyping is a class and has no timeline.???