Possible scope issue? DisplayList Issues and removeChild

In my work section i have a subnav which goes to motion, print, web, and all. I believe this is a scope issue but I just want to see what ya’ll think.

Once you load, let’s say motion, that will goto the root frame label “motion”.

Following that you will click a link there which will take you to a certain frame label in motionss_mc. Inside of motionss_mc I am dispatching an event to the root timeline to close motionss and open back up motion_mc if you so choose


motion_mc.twentythreemographthmb_mc.addEventListener(MouseEvent.CLICK, motionHandler8);
motion_mc.twentythreemographthmb_mc.buttonMode = true;

function motionHandler8(event:MouseEvent):void {
    if (!motionss_mc) {
        motionss_mc = new mc_motionss();
        motionss_mc.addEventListener("closemotionButtonClick2", backmotionssClicked2);
        motionss_mc.x = 225;
        motionss_mc.y = 200;
    }
motionss_mc.gotoAndStop("twentythree")
    addChild(motionss_mc);
    removeChild(motion_mc);
}

function backmotionssClicked2(e:Event):void {
    trace("clickedtrue");
    if (!motion_mc) {
        motion_mc = new mc_motion();
        motion_mc.x = 225;
        motion_mc.y = 200;
    }
    addChild(motion_mc);
    removeChild(motionss_mc);
}

That would be the backmotionss_Clicked2 function.

So in the subnav and continue to a link, close that link with the backmotionss_Clicked2 function then navigate to another section of the subnav…When I do this in that order, motion_mc stays at that section that is currently loaded…

So I am trying to clear it with this:


var motion_mc = motion_mc

workcatagorydropdown_mc.catagoryinteractive_mc.addEventListener(MouseEvent.CLICK, interactiveHandler);

function interactiveHandler(event:MouseEvent):void {

	newRoot.gotoAndStop("web");
	stage.invalidate();
	stage.addEventListener(Event.RENDER, renderedI);

}
function renderedI(e:Event) {

	motion_mcExistsI();
	stage.removeEventListener(Event.RENDER,renderedI);

}

function motion_mcExistsI():void {
	if (motion_mc!=null) {
		if (motion_mc.stage!=null) {
			trace("motion does exist");
			removeChild(motion_mc);
		} else {
			trace("no motion does not exist");
		}
	}
}

Please note that the following code is inside of the subnav which is located a few pages deep. Notice the usage of root.