Code in external swf only partially executing when loaded into a host swf

One of the swf files in my project is acting strangely.
The file compiles perfectly, and is functional when running stand-alone.
If I try to load it into the main swf in my project, the code stops executing just prior to the first for…loop.

To find out where the code was stopping, I placed a textfield on the stage named “stageText”, and assigned different strings to it at various points in the flow of actionscript.
It stops executing immediately after [COLOR=“Blue”]stageText.text = “init2”;[/COLOR], and just before the first for…loop. (see comments in code)

What am I missing here?
Why is the code stopping at the for loop?
Why does it only happen when the file is loaded into another swf?

thanks in advance.


import gs.*;
import gs.easing.*;

var locationsXML:XML;
locationsXML = 
<LOCATIONS>

<STORE TITLE="Sunrise BTO" ADDRESS="6860 E. Sunrise Road, Tucson, AZ
Ventana Village
in the Basha's Shopping Center" CONTACT="[email protected]" MAP="maps/sunriseBTO.png">
<IMAGE LARGE="img/img1.jpg" SMALL="thm/thm1.jpg"/>
<IMAGE LARGE="img/img2.jpg" SMALL="thm/thm2.jpg"/>
<IMAGE LARGE="img/img3.jpg" SMALL="thm/thm3.jpg"/>
<IMAGE LARGE="img/img4.jpg" SMALL="thm/thm4.jpg"/>
<IMAGE LARGE="img/img5.jpg" SMALL="thm/thm5.jpg"/>
<IMAGE LARGE="img/img6.jpg" SMALL="thm/thm6.jpg"/>
<IMAGE LARGE="img/img7.jpg" SMALL="thm/thm7.jpg"/>
<IMAGE LARGE="img/img8.jpg" SMALL="thm/thm8.jpg"/>
<IMAGE LARGE="img/img9.jpg" SMALL="thm/thm9.jpg"/>
<IMAGE LARGE="img/img10.jpg" SMALL="thm/thm10.jpg"/>
<IMAGE LARGE="img/img11.jpg" SMALL="thm/thm11.jpg"/>
<IMAGE LARGE="img/img12.jpg" SMALL="thm/thm12.jpg"/>
<IMAGE LARGE="img/img13.jpg" SMALL="thm/thm13.jpg"/>
<IMAGE LARGE="img/img14.jpg" SMALL="thm/thm14.jpg"/>
<IMAGE LARGE="img/img15.jpg" SMALL="thm/thm15.jpg"/>
<IMAGE LARGE="img/img16.jpg" SMALL="thm/thm16.jpg"/>
<IMAGE LARGE="img/img17.jpg" SMALL="thm/thm17.jpg"/>
<IMAGE LARGE="img/img18.jpg" SMALL="thm/thm18.jpg"/>
</STORE>

<STORE TITLE="Cortaro BTO" ADDRESS="8295 N. Cortaro Road, Marana, AZ
Just West of I-10 on Cortaro Road" CONTACT="[email protected]" MAP="maps/cortaroBTO.png">
<IMAGE LARGE="img/img19.jpg" SMALL="thm/thm19.jpg"/>
<IMAGE LARGE="img/img20.jpg" SMALL="thm/thm20.jpg"/>
<IMAGE LARGE="img/img21.jpg" SMALL="thm/thm21.jpg"/>
<IMAGE LARGE="img/img22.jpg" SMALL="thm/thm22.jpg"/>
</STORE>

<STORE TITLE="Speedway BTO" ADDRESS="2721 E. Speedway Blvd, Tucson, AZ
North side of Speedway
between Country Club & Tucson Blvd." CONTACT="[email protected]" MAP="maps/speedwayBTO.png">
<IMAGE LARGE="" SMALL=""/>
</STORE>

<STORE TITLE="Greenville BTO" ADDRESS="1305 Wagner Ave, Greenville, OH
North Towne Plaza" CONTACT="[email protected]" MAP="maps/greenvilleBTO.png">
<IMAGE LARGE="img/img23.jpg" SMALL="thm/thm23.jpg"/>
<IMAGE LARGE="img/img24.jpg" SMALL="thm/thm24.jpg"/>
<IMAGE LARGE="img/img25.jpg" SMALL="thm/thm25.jpg"/>
<IMAGE LARGE="img/img26.jpg" SMALL="thm/thm26.jpg"/>
<IMAGE LARGE="img/img27.jpg" SMALL="thm/thm27.jpg"/>
<IMAGE LARGE="img/img28.jpg" SMALL="thm/thm28.jpg"/>
<IMAGE LARGE="img/img29.jpg" SMALL="thm/thm29.jpg"/>
<IMAGE LARGE="img/img30.jpg" SMALL="thm/thm30.jpg"/>
<IMAGE LARGE="img/img31.jpg" SMALL="thm/thm31.jpg"/>
<IMAGE LARGE="img/img32.jpg" SMALL="thm/thm32.jpg"/>
</STORE>

</LOCATIONS>;

stageText.text = "init1";

var pageNav:MovieClip = new PageNav();
pageNav.x = 0;
pageNav.y = 0;

var btnHolder:Sprite = new Sprite();
btnHolder.x = 0;
btnHolder.y = 100;
addChild(btnHolder);

var stores:int = int(locationsXML..STORE.length());
var sunriseImages:int = int(locationsXML..STORE[0].IMAGE.length());
var cortaroImages:int = int(locationsXML..STORE[1].IMAGE.length());
var speedwayImages:int = int(locationsXML..STORE[2].IMAGE.length());
var greenvilleImages:int = int(locationsXML..STORE[3].IMAGE.length());

var nodeCounts:Array = 
[
stores,
sunriseImages,
cortaroImages,
speedwayImages,
greenvilleImages
];

var mTarget:MovieClip;
var buttons:Array = new Array();
var boxes:Array = new Array();
var boxProps:Array = new Array();
var spacer:int = 5;
var btnNum:int = 4;

stageText.text = "init2";

// -------------------------------------------------------------------------------------
// CODE STOPS EXECUTING HERE IF THE FILE IS LOADED INTO ANOTHER SWF.
// COMPILES AND FUNCTIONS PERFECTLY AS A STAND-ALONE SWF.
// -------------------------------------------------------------------------------------

for (var i:int = 0; i < btnNum; i++)
{
	var b:MovieClip = new Btn();
	b.id = i;
	b.x = 0;
	b.y = (spacer + b.height) * i;
	b.buttonMode = true;
	b.mouseChildren = false;
	b.btnLabel.text = String(locationsXML..STORE*[email protected]);
	b.addEventListener(MouseEvent.CLICK, btnClick, false, 0, true);
	btnHolder.addChild(b);
	buttons.push(b);
}

stageText.text = "init3";

TweenGroup.allFrom(buttons, 1, {stagger:.2, alpha:0, onComplete:buildNav(nodeCounts[1], 0)});

function buildNav(boxNum:int, buttonID:int):void
{
	this.addChild(pageNav);
	pageNav.titleText.text = String(locationsXML..STORE[buttonID][email protected]);
	pageNav.addressText.text = String(locationsXML..STORE[buttonID][email protected]);
	pageNav.contactText.text = String(locationsXML..STORE[buttonID][email protected]);

	spacer = 2;
	var _rows:int = 3;
	var _cols:int = 12;
	var _boxCount:int = 0;

	for (var py:int = 0; py < _rows; py++)
	{
		for (var px:int = 0; px < _cols; px++)
		{
			var _box:Box = new Box();
			_box.x = (spacer + _box.width) * px;
			_box.y = (spacer + _box.height) * py;
			trace("boxNum" + boxNum);
			if (_boxCount < boxNum)
			{
				_box.id = _boxCount;
				_box.mouseEnabled = false;
				_box.buttonMode = true;
				_box.mouseChildren = false;
				TweenLite.to(_box, 0, {alpha:.6, tint:0xFFFFFF * Math.random()});
				_box.addEventListener(MouseEvent.MOUSE_OVER, boxOver, false, 0, true);
				_box.addEventListener(MouseEvent.MOUSE_DOWN, boxDown, false, 0, true);
			} else
			{
				_box.alpha = .1;
			}
			boxes.push(_box);
			pageNav.thumbHolder.addChild(_box);

			var _rect:Rectangle = new Rectangle(_box.x, _box.y, _box.width, _box.height);
			boxProps.push(_rect);
			_boxCount++;
		}
	}
	
	stageText.text = "init4";
	
	TweenGroup.allFrom(boxes, .05, {stagger:.05, alpha:0, onCompleteAll:enableBoxes});
	mTarget = MovieClip(boxes[0]);
}

stageText.text = "init5";

function btnClick(e:MouseEvent):void
{
	while (pageNav.thumbHolder.numChildren > 0)
	{
		pageNav.thumbHolder.removeChildAt(0);
	}
	boxes = [];
	buildNav(nodeCounts[e.target.id+1], e.target.id);
}

function boxOver(e:MouseEvent):void
{
	e.target.addEventListener(MouseEvent.MOUSE_OUT, boxOut, false, 0, true);
	TweenLite.to(e.target, .1, {scaleX:1.2, scaleY:1.2});
}

function boxOut(e:MouseEvent):void
{
	TweenLite.to(e.target, .1, {scaleX:1, scaleY:1});
}

function boxDown(e:MouseEvent):void
{
	trace("box clicked " + e.target.id);
}

var j:int;

function enableBoxes():void
{
	trace("enableBoxes");
	for (j = 0; j < boxes.length; j++)
	{
		var b:MovieClip = MovieClip(boxes[j]);
		b.mouseEnabled = true;
	}
	mTarget.mouseEnabled = false;
}

function disableBoxes():void
{
	trace("disableBoxes");
	for (j = 0; j < boxes.length; j++)
	{
		var b:MovieClip = MovieClip(boxes[j]);
		b.mouseEnabled = false;
	}
}