# Error #1009:Cannot access a property or method of a null object reference

**URL:** https://forum.kirupa.com/t/error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/292206
**Category:** Uncategorized
**Created:** [July 11, 2009, 2:40pm UTC](https://forum.kirupa.com/t/error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/292206 "2009-07-11T14:40:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Tedri\_Mark](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@Tedri\_Mark](https://forum.kirupa.com/u/Tedri_Mark)
#### Post date: [July 11, 2009, 2:40pm UTC](https://forum.kirupa.com/t/error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/292206/1 "2009-07-11T14:40:23Z")

</div>

I know there is at least one other thread on this error, and I’ve overcome it before with the ADDED\_TO\_STAGE listener, but this time I can’t seem to get it to work

I have this function:

```auto
private function preload(e:Event):void
        {
            var preloader = e.target;
            var bar = preloader.process;
            bar.scaleX += (count / numphot - bar.scaleX) * 0.1;
           
            if (bar.scaleX >= 0.95) {
               
                bar.scaleX = 1;
               
                //Fade out preloader
                Tweener.addTween( preloader, { alpha:0,
                                                 time:1,
                                                transition:"easeOutExpo",
                                                onComplete:function():void {
                                                   
                                                    //remove preloader ~ load complete
                                                    removeChild(preloader)
                                                   
                                                    changeTo(startFrom);
                                                   
                                                    // fade in screen, scroller, caption, tooltip
                                                    Tweener.addTween([container, iScroller, cap, prevbut, nextbut], {alpha:1, time:2});
                                                    state = true;
                                                }
                                                });
               
                // remove Enterframe event for preloader
                preloader.removeEventListener(Event.ENTER_FRAME, preload);
            }
        }

```

Which is called by this, first time around:

```auto
preloaderMain.addEventListener(Event.ENTER_FRAME, preload);

```

and then later on, when I’ve removed all the items from the scene and want to restart everything again, using this:

```auto
preload(null);

```

According to the debug console, this is what is causing the error:

```auto
var preloader = e.target;

```

Any ideas?
