Scrolling Thumbnails in MX?!?

Hi everyone,

I have searched the forums for an answer to this one and have trawled through several threads and I couldn’t find an answer to my problem!

Can anyone tell me if scrolling thumbnails with the photo gallery is possible with MX?

I have done the tutorial (after the previous gallery one) and my thumbnails don’t show up, I’ve checked the XML file and everything is how it should be (as far as I know anyway). I can’t open the source files that come with the Tutorial which makes me think that it’s because they’re MX 2004 so I can’t check against anything where I’ve gone wrong. This is why I think it may be because I’ve only got MX.

Sorry if there is an answer out there somewhere, but I just couldn’t find it.

Post your code and it may just be a simple ammendment to get it to work.

Thanks Defective,

Here is the code - I don’t understand enough to make changes myself just yet to get this to work so any help is appreciated. :thumb:


function loadXML(loaded) {

if (loaded) {

xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
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;
thumbnails_fn(i);

}
firstImage();

} else {

content = "file not loaded!";

}

}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {

if (Key.getCode() == Key.LEFT) {

prevImage();

} else if (Key.getCode() == Key.RIGHT) {

nextImage();

}

};
Key.addListener(listen);
previous_btn.onRelease = function() {

prevImage();

};
next_btn.onRelease = function() {

nextImage();

};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {

preloader.preload_bar._xscale = 100*loaded/filesize;

} else {

preloader._visible = false;
if (picture._alpha<100) {

picture._alpha += 10;

}

}

};
function nextImage() {

if (p<(total-1)) {

p++;
if (loaded == filesize) {

picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();

}

}

}
function prevImage() {

if (p>0) {

p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();

}

}
function firstImage() {

if (loaded == filesize) {

picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();

}

}
function picture_num() {

current_pos = p+1;
pos_txt.text = current_pos+" / "+total;

}
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<=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+(eval("thumbnail_mc.t"+k)._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {

p = this.pictureValue-1;
nextImage();

};
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);

}


That code looks like it will work fine with Flash MX, have you tried tracing?

I’m not too sure how to use the trace action and or what part I should be tracing. Can you help me out a bit more pleeease.

Thanks for being patient!

thumbnail_mc.getNextHighestDepth()

is mx2004 code, replace it with 9978 (or any other number)

scotty(-:

nice catch scotty

=)

Hi Scotty,

Thanks for helping but I am very new to AS and don’t know what I’m supposed to be changing! Can you elaborate a bit more for me please?

Thanks

Look in the code for this line

thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());

and change it in

thumbnail_mc.createEmptyMovieClip("t"+k, 9978);

scotty(-:

I had tried that but there was no change. Any other ideas?

Oops, the moviecliploader is Flash 7 as well…

scotty(-:

Hi Scotty,

I’ve done a search again and haven’t managed to find a solution to this. There are a few threads with the same problem but no solutions!! Can you give any further help?

Thanks

Dawn

Try this (not tested)
Change the loadXml function like this

function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		description = [];
		thumbnails = [];
		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;
		}
		firstImage();
		thumbnails_fn();
	} else {
		content = "file not loaded!";
	}
}

And the thumbnails_fn like this

var k = 0;
function thumbnails_fn() {
	var thumb = thumbnail_mc.createEmptyMovieClip("t"+k, 999+k);
	var temp = this.createEmptyMovieClip("temp"+k, k);
	thumb.loadMovie(thumbnails[k]);
	temp.onEnterFrame = function() {
		if (thumb._width) {
			thumb._x = hit_left._x+(thumb._width+5)*k;
			thumb.pictureValue = k;
			thumb.onRelease = function() {
				p = this.pictureValue-1;
				nextImage();
			};
			thumb.onRollOver = function() {
				this._alpha = 50;
				thumbNailScroller();
			};
			thumb.onRollOut = function() {
				this._alpha = 100;
			};
			nextThumb();
			delete this.onEnterFrame;
		}
	};
}
function nextThumb() {
	k<total-1 ? (k++, thumbNails_fn) : null;
}

scotty(-:

Thanks Scotty, we’re getting somewhere now but not quite there yet!!! Only the first thumbnail is showing, I changed the alpha to 0 on the rollover to see if they were loading underneath and they don’t seem to be. Any ideas!!

<creep>Thanks so much for helping me out with this</creep>:)

There’s a typo in my code

function nextThumb() {
    k<total-1 ? (k++, thumbnails_fn) : null;
}

watch the n in thumbnails_fn :slight_smile:

scotty(-:

It’s still not working;(

Is it worth me posting the code again?

Can you post your fla?

scotty(-:

Sure, here you go.

My bad, I’ve forgotten the two brackets ‘()’ behind the function, the nextThumb function should look like this

function nextThumb() {
    k<total-1 ? (k++, thumbnails_fn()) : null;
}

scotty(-: