# Problem controlling main timeline

**URL:** <https://forum.kirupa.com/t/problem-controlling-main-timeline/298603>\
**Category:** flash\
**Created:** [October 21, 2009, 6:52pm UTC](https://forum.kirupa.com/t/problem-controlling-main-timeline/298603 "2009-10-21T18:52:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alejandroy](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alejandroy](https://forum.kirupa.com/u/alejandroy)\
**Post date:** [October 21, 2009, 6:52pm UTC](https://forum.kirupa.com/t/problem-controlling-main-timeline/298603/1 "2009-10-21T18:52:50Z")

</div>

I’m a complete noob in AS3. I’m having a pretty weird problem and for the life of me, I can’t figure it out.

I have a main movieclip, which includes a main menu. The menu buttons are set so that they jump to a frame label where they load an external swf. Pretty vanilla.

When I test the movie all by itself, the menu buttons do what they are supposed to do. I even get the message that the movie can’t find the swf that it’s supposed to load (because of the way I have the file paths set for the site).

But when I actually load and external swf, I get the following error messages:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at services\_ds\_fla::MainTimeline/frame1()  
Load Complete  
TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at MethodInfo-455()  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at flash.display::Stage/dispatchEvent()  
at services\_ds\_fla::MainTimeline/init()  
at flash.display:DisplayObjectContainer/addChild()  
at main\_ds\_fla::MainTimeline/completeHandler()

When I try clicking on one of the menu buttons to move to another frame, I get the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at main\_ds\_fla::MainTimeline/frame40()  
at flash.display::MovieClip/gotoAndPlay()  
at main\_ds\_fla::MainTimeline/homeClickHandler()

This is the code for preloading files:

```php
//preloader
var mcExt:MovieClip;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

function progressHandler(evt:ProgressEvent):void {
    var percent:Number = Math.round(evt.bytesLoaded * 100 / evt.bytesTotal);
    percentTxt.text = percent + "%".toString();
    progress_mc.gotoAndStop(percent);

}
function completeHandler(evt:Event) {
    trace("Load Complete");
    this.percentTxt.visible = false;
    this.progress_mc.visible = false;
    this.percentTxt = null;
    mcExt = MovieClip(loader.contentLoaderInfo.content);
    extContainer.addChild(mcExt);
}

```

This is the code I placed at the frames to actually fire the preload event:

```php
stop();
this.percentTxt.visible = true;
this.progress_mc.visible = true;
loader.load(new URLRequest( "swf/company_ds.swf" ));

```

Finally, this is the code used for the menu:

```php
//Dummies Menu buttons
for (var i:Number=0; i<7; i++) {
    dumMenu["btn_" + i].buttonMode = true;
    dumMenu["btn_" + i].addEventListener(MouseEvent.CLICK, dumClickHandler);
   
    function dumClickHandler(evt:MouseEvent):void {
        switch (evt.currentTarget) {
            case dumMenu.btn_1 :
                trace("button01");
                    this.gotoAndPlay("company");
                break;
          
        }
    }
}

```

I don’t know what I am doing wrong. Maybe It has to do whith the way I’m preloading the files? Please help, I’m kinda desperate.

Peace
