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:
//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:
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:
//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