10 Replies Latest reply on Sep 17, 2007 11:01 PM by Greg Dove

    Null object references

    Beatie3 Level 1
      O.K. I've got my classes talking to one another - yay - but now I'm trying to draw onto an image loaded into a scrollpane and it's telling me it's not really there. I've used trace(this.parent); on holder_sp and it's coming up as null even though I can see it and it's loader image on the stage. My graphic is fine and lives on the stage. I'm clear on the transform matrix to get it into a bitmap, but I want to add the image to the bitmap and the add the line object to it. I'm so close to finished I promise once this is over you won't see me for a while. Sorry to be a pest.
        • 1. Re: Null object references
          Beatie3 Level 1
          • 2. Null object references
            Greg Dove Level 4
            try changing this:
            var image:Bitmap = Bitmap(holder_sp.content);

            var image:Bitmap = Bitmap(scrollPane_.content);

            • 3. Re: Null object references
              Beatie3 Level 1
              Hi GWD, thank you for trying, but it didn't like that. I've actually got it successfully creating the image bitmap and the bitmapData object in the loading.as, but the scrollpane is still null. I'm adding the scrollpane like this now:


              where "_fla" is a reference to the MovieClip. If I add it like this:


              It still traces null and my drawing code guide and line disappear. If I trace(getChildIndex) it returns "function Function(){}".

              All very puzzling. I seem to have all the pieces but I can't get the bastards together. I think kglad's suggestion of passing a parameter to the class via a method would prolly get it working, but I've tried to do that and so far failed miserably. :'-(

              But thank you for trying.

              • 4. Re: Null object references
                SymTsb Level 2
                _fla.stage.addChild( holder_sp ) is not valid as code so you shouldn't expect it to draw anything to the stage.

                stage does not mean the same thing that it did in AS2.

                Beatie do you mind sending me your FLA so I can look at it? I see a few different things that could fire of a null object reference but it would help to get you on the right path with the actual file
                • 5. Re: Null object references
                  Beatie3 Level 1
                  Thank you, SymTsb. The _fla part was a parameter representing the movieclip that was passed to the class constructor like this:

                  public function Loading(fla:MovieClip,s:String) {

                  So it did add the scollpane but put it on top of my other sprites. I think my problem is with classes and referencing and instance methods vs. functions and the whole class business really. I've put all the files here.. I just want to get hold of the bitmap I created in Loading.as so I can draw the line variable onto it from the main class and make a jpeg that can be downloaded. It's the home stretch but driving me batty.

                  Thank you very much for having a look,
                  Beatie :D
                  • 6. Re: Null object references
                    SymTsb Level 2
                    Beatie, I'm getting an IOError when selecting an image to upload. Have you noticed this as well?
                    • 7. Re: Null object references
                      Beatie3 Level 1
                      I've got it working through my virtual server with PHP. It won't upload without that or a similar setup.
                      • 8. Re: Null object references
                        SymTsb Level 2
                        I need the upload.php file that you have on your local system. I can't test without it.
                        • 9. Null object references
                          Beatie3 Level 1
                          I put upload.php in the zip file. I'll try sending it again. It's here
                          • 10. Re: Null object references
                            Greg Dove Level 4
                            You must have made a number of changes since my last 'version' - that's normal its called work ;-) - the change I mentioned earlier removed the error after I put your bitmap code in mouseUpHandler on my older version:
                            Cannot access a property or method of a null object reference. at Main/mouseUpHandler()
                            because holder_sp was a private member of one of your other classes but it was called scrollPane_ (and used in the constructor call to that other class) called from Main.as. So when I changed the name to the one that was used in Main.as the error went away.

                            But I guess there's been a number of changes. I'll download the latest version and see if I can figure it out it later on today.