Removing Bandwidth Detector Makes swf stop working

Hi,

I have a project where I’m removing code for bandwidth detection, but after I remove it, my code in the }else{ won’t execute anymore like it did before. Not sure what I’m missing? Maybe a pair of curly braces somewhere? Here is before, and after bandwidth code removal:

---------- BEFORE (works): ----------

stop();

images_xml = new XML();
images_xml.onLoad = startImageViewer;
images_xml.load(‘xml/flash.xml’);
images_xml.ignoreWhite = true;

// intialize variables
function startImageViewer(success) {
if (success == true) {
rootNode = images_xml.firstChild;
// ‘totalImages’ is the variable name set to correspond with the the dynamic text instance of ‘totalImages’
totalImages = rootNode.childNodes.length;
// [ totalImages = rootNode.childNodes.length; ] gets the total number of childNodes (total number of image and text files) in your .xml document
firstImageNode = rootNode.firstChild;
lastImageNode = rootNode.lastChild;
currentImageNode = firstImageNode;
// ‘currentIndex’ is the variable name set to correspond with the dynamic text instance of ‘currentIndex’
currentIndex = 1;
// [ currentIndex = 1; ] sets the viewer to play the first childNode (first image and text file) in your .xml document
updateImage(firstImageNode);
}
}

// Updates the current image with new image and text
function updateImage(newImageNode) {
// ‘imagePath’ is the variable name set to correspond with the .jpeg file name located in your .xml document
headline1 = rootNode.childNodes[0].attributes.headline1;
headline2 = rootNode.childNodes[0].attributes.headline2;

headline3 = rootNode.childNodes[1].attributes.headline1;
headline4 = rootNode.childNodes[1].attributes.headline2;

headline5 = rootNode.childNodes[2].attributes.headline1;
headline6 = rootNode.childNodes[2].attributes.headline2;

headline7 = rootNode.childNodes[3].attributes.headline1;
headline8 = rootNode.childNodes[3].attributes.headline2;

headline9 = rootNode.childNodes[4].attributes.headline1;
headline10 = rootNode.childNodes[4].attributes.headline2;

image1 = rootNode.childNodes[0].attributes.image1;
image2 = rootNode.childNodes[1].attributes.image2;
image3 = rootNode.childNodes[2].attributes.image3;
image4 = rootNode.childNodes[3].attributes.image4;
image5 = rootNode.childNodes[4].attributes.image5;

}

// *************************
// Bandwidth Detector
/*
Downloads a hidden test image from a predefined URL
and determines client bandwidth based on how
quickly the image is downloaded. Test image must
be ~12k in filesize (smaller filesizes result in inaccurate
detections on fast connections). Image is not cached due
to random string added to URL.

“Test” variable in calc_bandwidth(); is bandwidth value.
(~300kbps cable/DSL, ~20kbps dialup)

The text field on the stage can be safely removed.

*/
// *************************

// container for test image
this.createEmptyMovieClip(“imageMovieClip”,999);

// image test loader object
var testImage:MovieClipLoader = new MovieClipLoader();
var testListener:Object = new Object();

// timer during test image loading
testListener.onLoadStart = function(targetMovieClip:MovieClip):Void {
startTime = getTimer();
};

// handle test image loading
testListener.onLoadProgress = function(targetMovieClip:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
var imageLoaded:Number = Math.ceil(100*(numBytesLoaded/numBytesTotal));
datasize = numBytesTotal;
if (imageLoaded == 100) {
endTime = getTimer();
calc_bandwidth();
}
};

// kbps conversion
function calc_bandwidth() {
var offsetMilliseconds = endTime-startTime;
var offsetSeconds = offsetMilliseconds/1000;
var bits = datasize8;
var kbits = bits/1024;
var bandwidth:Number = kbits/offsetSeconds;
bandwidth = (bandwidth
(.93));
test = Math.round(bandwidth)+“kbps”;
// this is where you can put the if statement
if (bandwidth<57) {
// Load alternate content for low bandwidth users here:
} else {
// This is for high bandwidth users:

    // Create the image holders for external images
    var clipOne:MovieClip = this.createEmptyMovieClip("holder1", 1);
    var clipTwo:MovieClip = this.createEmptyMovieClip("holder2", 3);
    var clipThree:MovieClip = this.createEmptyMovieClip("holder3", 5);
    var clipFour:MovieClip = this.createEmptyMovieClip("holder4", 7);
    var clipFive:MovieClip = this.createEmptyMovieClip("holder5", 9);

    // Set counter for MovieClipLoader to 0
    var counter:Number = 0;

    // Preloader and MovieClipLoader
    my_mc = new MovieClipLoader();
    preload = new Object();
    my_mc.addListener(preload);
    preload.onLoadStart = function(targetMC) {
        holder1._alpha = 0;
        holder2._alpha = 0;
        holder3._alpha = 0;
        holder4._alpha = 0;
        holder5._alpha = 0;
    };
    preload.onLoadProgress = function(targetMC, lBytes, tBytes) {
        var totalBytes = holder1.getBytesTotal()+holder2.getBytesTotal()+holder3.getBytesTotal()+holder4.getBytesTotal()+holder5.getBytesTotal();
        var loadedBytes = holder1.getBytesLoaded()+holder2.getBytesLoaded()+holder3.getBytesLoaded()+holder4.getBytesLoaded()+holder5.getBytesLoaded();
        var percentDone = Math.round((loadedBytes/totalBytes)*100);
        preloader.gotoAndPlay(percentDone);
        preloader.load_percentage.txtPercentage = percentDone+"%";
    };
    preload.onLoadComplete = function(targetMC) {
        // Increment MovieClipLoader counter by one
        counter = counter+1;
        // If MovieClipLoader counter equels this, then go to frame 2
        if (counter == 4) {
            gotoAndPlay("animation");
        }
    };
}
// Load external images into the holders
my_mc.loadClip(image1,"holder1");
my_mc.loadClip(image2,"holder2");
my_mc.loadClip(image3,"holder3");
my_mc.loadClip(image4,"holder4");
my_mc.loadClip(image5,"holder5");

}

// load the test image and prevent it from being cached
testImage.addListener(testListener);
testImage.loadClip("http://www.dquinn.net/home/im/layout/header.gif"+"?"+new Date().getTime(),imageMovieClip);

// hide test image while it’s loading
imageMovieClip._alpha = 0;

--------- AFTER (doesn’t work): -----------

stop();

images_xml = new XML();
images_xml.onLoad = startImageViewer;
images_xml.load(‘xml/flash.xml’);
images_xml.ignoreWhite = true;

// intialize variables
function startImageViewer(success) {
if (success == true) {
rootNode = images_xml.firstChild;
// ‘totalImages’ is the variable name set to correspond with the the dynamic text instance of ‘totalImages’
totalImages = rootNode.childNodes.length;
// [ totalImages = rootNode.childNodes.length; ] gets the total number of childNodes (total number of image and text files) in your .xml document
firstImageNode = rootNode.firstChild;
lastImageNode = rootNode.lastChild;
currentImageNode = firstImageNode;
// ‘currentIndex’ is the variable name set to correspond with the dynamic text instance of ‘currentIndex’
currentIndex = 1;
// [ currentIndex = 1; ] sets the viewer to play the first childNode (first image and text file) in your .xml document
updateImage(firstImageNode);
}
}

// Updates the current image with new image and text
function updateImage(newImageNode) {
// ‘imagePath’ is the variable name set to correspond with the .jpeg file name located in your .xml document
headline1 = rootNode.childNodes[0].attributes.headline1;
headline2 = rootNode.childNodes[0].attributes.headline2;

headline3 = rootNode.childNodes[1].attributes.headline1;
headline4 = rootNode.childNodes[1].attributes.headline2;

headline5 = rootNode.childNodes[2].attributes.headline1;
headline6 = rootNode.childNodes[2].attributes.headline2;

headline7 = rootNode.childNodes[3].attributes.headline1;
headline8 = rootNode.childNodes[3].attributes.headline2;

headline9 = rootNode.childNodes[4].attributes.headline1;
headline10 = rootNode.childNodes[4].attributes.headline2;

image1 = rootNode.childNodes[0].attributes.image1;
image2 = rootNode.childNodes[1].attributes.image2;
image3 = rootNode.childNodes[2].attributes.image3;
image4 = rootNode.childNodes[3].attributes.image4;
image5 = rootNode.childNodes[4].attributes.image5;

}

// Create the image holders for external images
var clipOne:MovieClip = this.createEmptyMovieClip(“holder1”, 1);
var clipTwo:MovieClip = this.createEmptyMovieClip(“holder2”, 3);
var clipThree:MovieClip = this.createEmptyMovieClip(“holder3”, 5);
var clipFour:MovieClip = this.createEmptyMovieClip(“holder4”, 7);
var clipFive:MovieClip = this.createEmptyMovieClip(“holder5”, 9);

// Set counter for MovieClipLoader to 0
var counter:Number = 0;

// Preloader and MovieClipLoader
my_mc = new MovieClipLoader();
preload = new Object();
my_mc.addListener(preload);
preload.onLoadStart = function(targetMC) {
holder1._alpha = 0;
holder2._alpha = 0;
holder3._alpha = 0;
holder4._alpha = 0;
holder5._alpha = 0;
};
preload.onLoadProgress = function(targetMC, lBytes, tBytes) {
var totalBytes = holder1.getBytesTotal()+holder2.getBytesTotal()+holder3.getBytesTotal()+holder4.getBytesTotal()+holder5.getBytesTotal();
var loadedBytes = holder1.getBytesLoaded()+holder2.getBytesLoaded()+holder3.getBytesLoaded()+holder4.getBytesLoaded()+holder5.getBytesLoaded();
var percentDone = Math.round((loadedBytes/totalBytes)*100);
preloader.gotoAndPlay(percentDone);
preloader.load_percentage.txtPercentage = percentDone+"%";
};
preload.onLoadComplete = function(targetMC) {
// Increment MovieClipLoader counter by one
counter = counter+1;
// If MovieClipLoader counter equels this, then go to frame 2
if (counter == 4) {
gotoAndPlay(“animation”);
}
};

// Load external images into the holders
my_mc.loadClip(image1,“holder1”);
my_mc.loadClip(image2,“holder2”);
my_mc.loadClip(image3,“holder3”);
my_mc.loadClip(image4,“holder4”);
my_mc.loadClip(image5,“holder5”);