Can someone please explain to me how this code works?

Hi Guys,

I am pretty new to AS … i am not too sure how this resizing AS actually get the size of the image n dynmically resizes it … i hope someone can give me some detailed explanation on how this work.Would be pretty pointless if i just copy codes and not knowing how it really function. Any help is much appreicated :ne:


spacing = 10;
containerMC._alpha = 0;
var pArray = new Array();
var tArray = new Array();
var cur;
MovieClip.prototype.loadPic = function(pic) {
	cur = pic;
	this._alpha = 0;
	this.loadMovie(pArray[pic]);
	this._parent.onEnterFrame = function() {
		var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
		bar._visible = 1;
		per = Math.round((l/t)*100);
		if (l == t && containerMC._width>0 && containerMC._height>0) {
			var w = containerMC._width+spacing, h = containerMC._height+spacing;
			border.resizeMe(w, h);
			bar._visible = 0;
			containerMC._alpha = 0;
			picinfo.info.text = tArray[pic];
			delete this.onEnterFrame;
		} else {
			bar._width = per;
			//gives the bar a max width 100 
			picinfo.info.text = per+" % loaded";
		}
	};
};

MovieClip.prototype.resizeMe = function(w, h, pic) {
	var speed = 3;
	this.onEnterFrame = function() {
		this._width += (w-this._width)/speed;
		this._height += (h-this._height)/speed;
		nav._x = Math.round(this._x-this._width/2);
		nav._y = Math.round(this._y+this._height/2+spacing/2);
		shadowFollow();
		prevb._x = nav._x-5;
		nextb._x = nav._x+this._width+5;
		nextb._y = prevb._y=this._y-this._height/2;
		picinfo._y = nextb._y-5;
		picinfo._x = border._x-picinfo._width/2;
		if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
			this._width = w;
			this._height = h;
			containerMC._x = this._x-this._width/2+spacing/2;
			containerMC._y = this._y-this._height/2+spacing/2;
			containerMC._alpha = 100;
			delete this.onEnterFrame;
		}
	};
};

Here’s the FLA for the whole code …
Original FLA by scotty

http://www.kirupa.com/forum/attachment.php?attachmentid=9789&d=1109332771

Thanks Again