Complicated: Opening XML-Driven Images in a Pop-Up Window

Hello,

This sounds complicated but I’ve tried so many ways working with the on(release) portion of this code to generate a pop-up window to display images called from an XML file but it just generates errors.

function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		description = [];
		thumbnails = [];
		links = [];
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
			thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
			links* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
			thumbnails_fn(i);
		}
		firstImage();
	} else {
		content = "file not loaded!";
	}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("screenshots/images.xml");
///////////////////////////////////// 
function thumbNailScroller() {
	// thumbnail code! 
	this.createEmptyMovieClip("tscroller", 1000);
	scroll_speed = 10;
	tscroller.onEnterFrame = function() {
		if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
			if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
				thumbnail_mc._x -= scroll_speed;
			} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
				thumbnail_mc._x += scroll_speed;
			}
		} else {
			delete tscroller.onEnterFrame;
		}
	};
}
function thumbnails_fn(k) {
	thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
	tlistener = new Object();
	tlistener.onLoadInit = function(target_mc) {
		target_mc._x = hit_left._x+(target_mc._width+8)*k;
		target_mc.pictureValue = k;
		target_mc.onRelease = function() {
			getURL(links[k]);  //TRIED TO CHANGE THIS AROUND
		};
		target_mc.onRollOver = function() {
			this._alpha = 50;
			thumbNailScroller();
		};
		target_mc.onRollOut = function() {
			this._alpha = 100;
		};
	};
	image_mcl = new MovieClipLoader();
	image_mcl.addListener(tlistener);
	image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

The commented part is what I’ve been trying to play with. The image loads fine in the same browser window. But what about opening it in a pop-up? I know the JS script is as follows:

getURL("javascript:NewWindow=window.open("my.html",'newWin','width=800,height=600');NewWindow.focus();void(0);");

Which works on regular on(release) commands but involving variables, it makes it complicated… not impossible though? I’ve tried to incorporate links[k] in so many ways into that line, but it’s not happening. I’ve declared a new variable for it and even isolated it by concatenation, and even though the code makes sense, it’s not working :puzzled:

Any ideas?

[quote=Maive;2323653]Hello,

This sounds complicated but I’ve tried so many ways working with the on(release) portion of this code to generate a pop-up window to display images called from an XML file but it just generates errors.

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        description = [];
        thumbnails = [];
        links = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
            links* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
            thumbnails_fn(i);
        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("screenshots/images.xml");
///////////////////////////////////// 
function thumbNailScroller() {
    // thumbnail code! 
    this.createEmptyMovieClip("tscroller", 1000);
    scroll_speed = 10;
    tscroller.onEnterFrame = function() {
        if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
            if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
                thumbnail_mc._x -= scroll_speed;
            } else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
                thumbnail_mc._x += scroll_speed;
            }
        } else {
            delete tscroller.onEnterFrame;
        }
    };
}
function thumbnails_fn(k) {
    thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
    tlistener = new Object();
    tlistener.onLoadInit = function(target_mc) {
        target_mc._x = hit_left._x+(target_mc._width+8)*k;
        target_mc.pictureValue = k;
        target_mc.onRelease = function() {
            getUR L(links[k]);  //TRIED TO CHANGE THIS AROUND
        };
        target_mc.onRollOver = function() {
            this._alpha = 50;
            thumbNailScroller();
        };
        target_mc.onRollOut = function() {
            this._alpha = 100;
        };
    };
    image_mcl = new MovieClipLoader();
    image_mcl.addListener(tlistener);
    image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

The commented part is what I’ve been trying to play with. The image loads fine in the same browser window. But what about opening it in a pop-up? I know the JS script is as follows:

getURL("javascript:NewWindow=window.open("my.html",'newWin','width=800,height=600');NewWindow.focus();void(0);");

Which works on regular on(release) commands but involving variables, it makes it complicated… not impossible though? I’ve tried to incorporate links[k] in so many ways into that line, but it’s not happening. I’ve declared a new variable for it and even isolated it by concatenation, and even though the code makes sense, it’s not working :puzzled:

Any ideas?[/quote]
Does the link var trace out okay? Does this not work?:
getURL(“javascript:NewWindow=window.open(links[k],‘newWin’,‘width=800,height=600’);NewWindow.focus();void(0);”);

Yes, the link var works, it links to the image fine in the same browser window. But if I wrote out the JS like that (which makes sense), the browser generates an error with the details: ‘links’ is undefined. If I create a new variable to represent links[k], it’ll say that that variable is undefined. If I concatenate the long JS script to isolate links[k], same error.

I’m thinking I may have to make changes to the overall script :bored:

Any ideas? :expressionless: