Loading/unloading external swfs with buttons

Sorry if this has been asked before, but I’ve read through tons of forums and tutorials and can’t quite get my project to work, though it seems so basic.

NOTE: I’m a designer with minimal programming knowledge, so most of my code is just modified from various sources! :slight_smile:

I have a row of buttons on the main stage, and I’d like the viewer to click a button to open each movie and control the movie (pause, play, stop, return to main).
The first button function (showVideo), actually works because it’s a flv and I followed a tutorial for the controls on that one.
The others are swfs from regular Flash files and I’m confused about where to place the user controls (within the main stage, or the individual swfs)
I currently keep getting this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TNG_fla::MainTimeline/frame1()

Any help would be greatly appreciated!


var thisMC:MovieClip = new MovieClip();

var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.INIT, doneThisLoading);

function doneThisLoading(e:Event):void {
	thisMC = MovieClip(myLoader.content);
	myLoader.unload();
	
	stage.addChild(thisMC);
	thisMC.gotoAndPlay(1);
	thisMC.addEventListener(Event.ENTER_FRAME, runOnce);
}


btnOpenWelcome.addEventListener(MouseEvent.CLICK, showVideo);

function showVideo(evt:MouseEvent):void {
	btnOpenWelcome.visible = false;
	btnOpenCorp.visible = false;
	btnOpenHR.visible = false;
	myLoader.load(new URLRequest("Welcome.swf") );
}

btnOpenCorp.addEventListener(MouseEvent.CLICK, showCorp);

function showCorp(evt:MouseEvent):void {
	btnOpenWelcome.visible = false;
	btnOpenCorp.visible = false;
	btnOpenHR.visible = false;
	myLoader.load(new URLRequest("TNG-Orientation_corp.swf") );
}

btnOpenHR.addEventListener(MouseEvent.CLICK, showHR);

function showHR(evt:MouseEvent):void {
	btnOpenWelcome.visible = false;
	btnOpenCorp.visible = false;
	btnOpenHR.visible = false;
	myLoader.load(new URLRequest("TNG-Orientation_hr.swf") );
}

function runOnce(e:Event):void {
	if (thisMC.currentFrame == thisMC.totalFrames) {
		stage.removeChild(thisMC);
		thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);
		btnOpenWelcome.visible = true;
		btnOpenCorp.visible = true;
		btnOpenHR.visible = true;
	}
}
stop();