I am using Sen’s xml photo gallery tutorial (link here ) which loads images, thumbnails, and text via xml (and some text files for lengthy photo descriptions).
I was wondering if it were possible to get properties like _height or _width of the thumbnails and then apply scaling to them. Long story short - I have both wide and tall thumbs and I want to put in an if statement that says if something is tall then scale it to be the same height as the wide ones but I am having trouble targeting the thumbs.
This is the code to load the thumbs:
for (child = 0; child < count; child++){
currentThumb=menu_mc.createEmptyMovieClip("thumbnail"+child,child);
//space the thumbs
currentThumb._x = child * 60;
image = currentThumb.createEmptyMovieClip("thumbnail_image",0);
//load the thumbs
image.loadMovie(currentPicture.attributes.THUMB);
//assign some other attributes
currentThumb.NAME = currentPicture.attributes.NAME;
currentThumb.IMAGE = currentPicture.attributes.IMAGE;
currentThumb.TEXT = currentPicture.attributes.TEXT;
//etc.
I think you can use the code I gave you a few weeks ago:)
var a = 100;
for (child=0; child<count; child++) {
currentThumb = menu_mc.createEmptyMovieClip("thumbnail"+child, child);
//space the thumbs
currentThumb._x = child*60;
image = currentThumb.createEmptyMovieClip("thumbnail_image", 0);
//load the thumbs
image.loadMovie(currentPicture.attributes.THUMB);
loadMeter(image);
//assign some other attributes
currentThumb.NAME = currentPicture.attributes.NAME;
currentThumb.IMAGE = currentPicture.attributes.IMAGE;
currentThumb.TEXT = currentPicture.attributes.TEXT;
//etc.
}
function loadMeter(clip) {
tmp = this.createEmptyMovieClip("temp"+a, a++);
tmp.onEnterFrame = function() {
var tot = clip.getBytesTotal();
trace(clip);
var loa = clip.getBytesLoaded();
if (tot == loa && tot>0 && clip._width>0 && clip._height>0) {
//if it's a portrait picture, give it the heigth of a landscape one
//in your case 75 and scale the width proportionally
if (clip._height>=clip._width) {
clip._height = 75;
clip._xscale = clip._yscale;
}
delete this.onEnterFrame;
}
};
}
Works brilliantly of course! :thumb: Knew I left out something . . .
But now here is a puzzle for you (or anyone else who wants to take a crack at it ).
Sen’s script has the thumbs loading into depths so the currentThumb, whichever it may be, gets it’s _x property set to 60 pixels more than the last _x coordinate, which means that there are gaps between images that aren’t the same size. Any idea how I can use the width of the previous thumb instead of a straight number like 60?
LOL, off course… stupid me :stunned: the width is set after it’s fully loaded.
So we must set the thumbs after the if statement. It’s rather late now, if tomorrow no one else has helped you, i’ll give it a try:)
Thanks scotty! It’s hard with the xml stuff to know when the pics are loaded. I’d of thought that once the loadMovie command is executed then its good to go but I guess that is no guarantee in the processor world. I look forward to hearing more from you tomorrow!
p.s. You probably can guess this but I’ll be working on getting the resize prototype to work in there too . . .
you know, I re-did this file for the XML tutorial Im writing and I realized I spent too much time commenting so theres a few “errors” mostly things like variables that should be local but werent declared as being so etc. :!: Looks ike you guys got it all figured out though
Okay well I got the thumbs loading nicely (thanks again Scotty ) and I even got the resize thing going and the finite menu for the thumbs all by my little 'ol self (this is truly impressive for those that know me).
Anyway, to get the resize to work I had to change this:
image_mc.loadMovie(this.IMAGE);
to this:
image_mc.loadPic(this.IMAGE);
loadPic is a prototype function from the resizing slideshow thread which is essentially:
MovieClip.prototype.loadPic = function(pic) {
//uncommented next line
image_mc._alpha = 0;
this.loadMovie(pic);
//loadbar._visible = 1;
this._parent.onEnterFrame = function() {
var t = image_mc.getBytesTotal(), l = image_mc.getBytesLoaded();
var percent = Math.round(100*l/t);
if (t != 0 && Math.round(l/t) == 1 && image_mc._width>0 && image_mc._height>0) {
var w = image_mc._width+spacing, h = image_mc._height+spacing;
border.resizeMe(w, h);
//loadbar._visible = 0;
//loadertxt.text = " ";
delete this.onEnterFrame;
} else {
//loadertxt.text = percent+" % loaded";
//loadbar._width = percent;
}
};
};
I don’t have the preloader up yet so its commented out.
ANYWAY somehow I managed to lose the TEXT attribute from the xml file :hair: (see xml code at start of this thread). How did I do that? It was working fine (I think) before I changed the loadMovie to a call to a function.
Any hints on what to look out for would be splendid. :love:
Okay and while I’m at it. I have 200 images and I am trying to load 20 at a time per xml file. So I have xmlgallery.xml, xmlgallery2.xml, xmlgallery3.xml, etc. I am calling the xml load function from buttons. So button 1 has
If I click button1 it loads fine. If I click button2 only the very last thumb and pic load. If I click on button1 again I get nothing. If, from startup, I click button2 I get nothing?
Ack! I would love to send you my files but I’m headed out of town (again, sigh) for a week so unfortunately I have to put it off :hair: until I get back.