8 Replies Latest reply on Dec 3, 2009 7:33 PM by Ned Murphy

    1009 Error (Null Object Call) Flash CS4

    North 60

      Hi All

      I'm very new to Flash (this is my first attempt) and am trying to figure out how to deal with this error I'm getting.

      The code is supposed to animate a flyout menu on a mouse hover event.

      I'm actually surprised I have made it this far before getting stumped.

      Please help, My brain hurts. 

       

      Here is my code:

       

      import fl.transitions.Tween;
      import fl.transitions.easing.*;

       

      var FishingSub_mc:MovieClip = FishingSub_mc;
      var Fishing_btn:SimpleButton = Fishing_btn;

       

      function FishingFlyout (event:MouseEvent):void
          {
          var FishingTween:Tween = new Tween (FishingSub_mc,"y",Regular.easeOut,0,40,20,false);
          }
          Fishing_btn.addEventListener(MouseEvent.MOUSE_OVER,FishingFlyout);

       

      And here is the error I'm getting:


      TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at menu_fla::MainTimeline/frame1()[menu_fla.MainTimeline::frame1:12]

       

      Thanks for your help.

       

      Dave

        • 1. Re: 1009 Error (Null Object Call) Flash CS4
          Ned Murphy Adobe Community Professional & MVP

          I am not sure why you have these two lines...

           

          var FishingSub_mc:MovieClip = FishingSub_mc;
          var Fishing_btn:SimpleButton = Fishing_btn;

           

          If those two objects are items on your stage, then you should not need those lines of code at all. The important thing is to be sure that you have the instance names assigned to the objects.  Whichever object is being targeted on line 12 is out of scope when that code executes.

           

          Some of the possible reasons...

           

          - the object doesn't have the instance name assigned to it

           

          - the object animates into the movie and does not have that instance name assigned at each keyframe

           

          - the object is somewhere down a timeline when that code executes

          • 2. Re: 1009 Error (Null Object Call) Flash CS4
            North 60 Level 1

            Thanks for the reply.

            Those two lines of code are there to define two objects. They are on the stage but if I do not define them I recieve the two errors in the attached jpeg.

            As I said I have only just started programming and it's like learning Japanese to me. .

            • 3. Re: 1009 Error (Null Object Call) Flash CS4
              Ned Murphy Adobe Community Professional & MVP

              You do nt need those lines, you need to assign those instance names to the objects on the stage, and those objects need to exist in the frame (not the layer) where that code executes.  To give those objects instance names you select each one individually and then enter th name in the properties panel in the input field that says Instance Name

              • 4. Re: 1009 Error (Null Object Call) Flash CS4
                North 60 Level 1

                You're correct but for some reason Flash was unable to find the objects.

                I did a little messing around and it now is past that issue and on to the next one.

                 

                So here is my revised code:

                 

                1     import fl.transitions.Tween;
                2     import fl.transitions.easing.*;
                3
                4     function FishingFlyout (event:MouseEvent);void {
                5         var FishingFlyout:Tween = new Tween(FishingSub_mc,"y",Regular.easeOut,0,40,20,false);
                6     }
                7   Fishing_btn.addEventListener(MouseEvent.MOUSE_OVER,FishingFlyout);

                 

                And my new errors:

                 

                errors.JPG

                 

                What do ya think?

                 

                Tired of my newby questions yet. 

                • 5. Re: 1009 Error (Null Object Call) Flash CS4
                  North 60 Level 1

                  Ok with a lot of head shaking and lost sleep and a ton of reading I'm getting closer to success.

                  My latest code revision is throwing only one compiler error, but I can't figure out what it actually want's me to do.

                  Probably something simple I'm just not seeing. I'm sure that once I get this last compiler error out of the way, I'll get to deal with run time errors!!!! yay!!!  

                   

                  So here's my latest code:

                   

                  1   import fl.transitions.Tween;
                  2   import fl.transitions.easing.*;
                  3

                  4   //Fishing Button Hover Action

                  5

                  6    var startY:Number = fishingSub_mc.y;
                  7   {

                  8    function fishingFlyout (event:MouseEvent); void
                  9    var fishFlyout:Tween = new Tween(FishingSub_mc,y,Regular.easeOut,startY,startY+40,20,false);
                  10  }
                  11  Fishing_btn.addEventListener(MouseEvent.MOUSE_OVER,fishingFlyout);

                   

                  And the error is:

                  On line 9

                   

                  1084: Syntax error: expecting identifier before var.

                   

                   

                  Can't figure out what it want's me to identify.

                  Any ideas O coding guru's??

                   

                   

                  Thanks

                   

                  Dave

                  • 6. Re: 1009 Error (Null Object Call) Flash CS4
                    Ned Murphy Adobe Community Professional & MVP

                    I lost touch with your plight, probably due to the delayed response time between our original discussions.   It's not the var that's causing the problem. In looking at your code the problem appears to be a semi-colon where a colon is called for...

                     

                    function fishingFlyout (event:MouseEvent); void

                     

                    (only enlarged for clarity, not being a wise-a__)

                     

                    should be...

                     

                    function fishingFlyout (event:MouseEvent): void

                    • 7. Re: 1009 Error (Null Object Call) Flash CS4
                      North 60 Level 1

                      I knew it was something simple.

                      Once I got the colon in there and rearranged the brackets plus a couple of other tweaks it does what I wanted it to do!!!!!  

                       

                      Thanks for pointing it out. The eye's don't work as well as they used to.

                       

                       

                       

                      Thanks

                       

                      Dave

                      • 8. Re: 1009 Error (Null Object Call) Flash CS4
                        Ned Murphy Adobe Community Professional & MVP

                        You're welcome, Dave