Hey all, I got this script off of here, sadly i cant find the souce again but its an xml/ flash gallery script with a preloader on all the images.
The script is perfect except I’m having trouble deciphering which bit of the action script loads the images (the big images which all have a name such as P1.jpg) into the level they are currently loading into.
I’ve been trying different methods with all the createEmptyMovieClips with no luck…
I’d really like to find out who wrote this script and how it works. The only other elements on the stage are a movieClip called container and another called border, which they seem to load into…
Thanks
Dave
myxml = new XML();
myxml.ignoreWhite = true;
myxml.onLoad = parseMe;
spacing = 0;
myxml.load("gallery.xml");
myarray = [];
path = "images/";
var cols;
function parseMe(success) {
if (success) {
cols = this.firstChild.attributes.cols;
//this * controls the colum that the images are shown in. By multiplying the comums from their original 4 colums with your chosen width.
for (var k = 0; k<this.firstChild.childNodes.length; k++) {
var pictures = this.firstChild.childNodes[k];
var objj = {};
for (var j in pictures.attributes) {
objj[j] = pictures.attributes[j];
}
myarray.push(objj);
}
init();
} else {
"FAILED TO LOAD DATA";
}
}
MovieClip.prototype.resizeMe = function(clip, w, h, id) {
var speed = 3;
clip._alpha = 0;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
info._y = Math.round(this._y-this._height/2-spacing-30);
shadowFollow();
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
this._width = w;
this._height = h;
clip._x = this._x-this._width/2+spacing/2;
clip._y = this._y-this._height/2+spacing/2;
info._y = Math.round(this._y-this._height/2-spacing-30);
clip._alpha += 10;
//info.text = id;
if (clip._alpha>90) {
clip._alpha = 100;
delete this.onEnterFrame;
}
}
};
};
var j = 0;
cliparray = [];
createEmptyMovieClip("paper", -1);
_global.preloaderf = function(klip) {
lb = cliparray[klip].getBytesLoaded();
tb = cliparray[klip].getBytesTotal();
//trace(cliparray[klip]);
l.mytext.text = "picture "+Number(klip+1)+" loading "+Math.floor(100*lb/tb)+" %";
if (myarray[klip].holder._width>0) {
myarray[klip].holder._visible = false;
myarray[klip].holder._x = Stage.width/2-myarray[klip].holder._width/2;
myarray[klip].holder._y = Stage.height/2-myarray[klip].holder._height/2;
clearInterval(arguments.callee.interval);
paper["btn"+klip]._alpha = 100;
paper["btn"+klip].enabled = true;
if (klip == 0) {
dopress.apply(paper["btn"+klip]);
}
if (klip<myarray.length-1) {
startfunction();
} else {
l.mytext.text = "";
}
}
};
function init() {
for (var i = 0; i<myarray.length; i++) {
var clap = createEmptyMovieClip("container"+i, i, -1);
clap._x = Stage.width;
clap._alpha = 0;
myarray*.holder = clap;
var clip = paper.attachMovie("btn", "btn"+i, i);
clip._x = i%cols*36+-226;
clip._y = Math.floor(i/cols)*36+218;
cliparray.push(clap);
clip.onPress = dopress;
clip._alpha = 20;
clip.enabled = false;
clip.ivar = i;
}
startfunction();
}
delete i;
delete clap;
delete clip;
function startfunction() {
var cap = paper["btn"+j].createEmptyMovieClip("p", -1);
cap._x = -10;
cap._y = -10;
cap.loadMovie(path+myarray[j].thumb);
this.onEnterFrame = function() {
if (paper["btn"+j].p._width) {
delete this.onEnterFrame;
myarray[j].holder.loadMovie(path+myarray[j].source);
preloaderf.interval = setInterval(preloaderf, 20, j);
j++;
}
};
}
var boo = this;
function dopress() {
for (var obj in cliparray) {
cliparray[obj]._visible = 0;
}
//myarray[this.ivar].holder._alpha = 100;
cliparray[this.ivar]._visible = true;
container.loadMovie(myarray[this.ivar].movie);
border.resizeMe(myarray[this.ivar].holder, myarray[this.ivar].holder._width, myarray[this.ivar].holder._height, this.ivar);
info.text = myarray[this.ivar].title;
}