Apparently this is a toughy… OR nobody really wants to help me out on this one.
I got this scroller, right… and it automatically generates thumbs within a mask, accordingly to an XML file.
UNFORTUNATELY the WIDTH of the thumb is static… bad thing… very bad.
I got the thing to dynamically be the width of the thumb MC the image-thumb is in, BUT it will only be the width it is BEFORE the image is loaded in, which means 0px width.
MovieClip.prototype.easeX = function(x) {
this.onEnterFrame = function() {
this._x = x-(x-this._x)/1.2;
if (Math.abs(x-this._x)<=1) {
delete this.onEnterFrame;
this._x = x;
}
};
};
images = new Array();
xml_file = "images2.xml";
xmlload = new XML();
xmlload.ignoreWhite = true;
xmlload.onLoad = function(ok) {
if (ok) {
count = this.firstChild.childNodes.length;
for (var i = 0; i<count; i++) {
curNode = this.firstChild.childNodes*;
images* = {path:curNode.childNodes[0].firstChild.nodeValue,link:curNode.childNodes[1].firstChild.nodeValue,caption:curNode.childNodes[2].firstChild.nodeValue};
}
boot();
} else {
trace("Could not load "+xml_file+".");
}
};
xmlload.load(xml_file);
// ------------------------------------------------------------
spacing = 1;
boot = function () {
for (var i = 0; i<images.length; i++) {
mc = container.attachMovie("thumbMC", "thumb"+i, i);
//the 56 is width of thumb
mc._x = i*(50+spacing);
mc.path = images*.path;
mc.link = images*.link;
mc.caption = images*.caption;
}
setRollOver();
};
setRollOver = function () {
this.onEnterFrame = function() {
if (this.mask.hitTest(_root._xmouse, _root._ymouse)) {
slideMenu();
}
};
};
slideMenu = function () {
diff = _xmouse-this._x;
scale = diff*100/this.mask._width;
target = -scale*(this.container._width-this.mask._width)/100;
this.arrows.easeX(diff);
this.container.easeX(target);
};
This is the complete code of the main MC - where the sroller is
MovieClip.prototype.backwards = function(){
this.onEnterFrame = function(){
this.prevFrame();
if(this._currentframe == 1) delete this.onEnterFrame;
}
}
loader.loadMovie(this.path);
percent = Math.floor(loader.getBytesLoaded()/loader.getBytesTotal()*100);
percentage.text = percent + "%";
aux.onEnterFrame = function() {
if(loader._width>0) {
delete this.onEnterFrame;
loader.onRollOver = function(){
delete over.onEnterFrame;
over.play();
}
loader.onRollOut = function(){
over.backwards();
}
loader.onRelease = function() {
_root.containerMC.loadPic (this._parent.link);
_root.captionMC.context.text = (this._parent.caption);
};
}
};
AS for the thumb MC
THIS is the code I’M thinking needs a little messing with, but I have failed misserably.
spacing = 1;
boot = function () {
for (var i = 0; i<images.length; i++) {
mc = container.attachMovie("thumbMC", "thumb"+i, i);
//the 50 is the static width of the thumb
mc._x = i*(50+spacing);
mc.path = images*.path;
mc.link = images*.link;
mc.caption = images*.caption;
}
setRollOver();
};
I’d REALLY love for that mc._x to be dynamic.
thanks in advance
pxa