Auto-resize border with attachMovie();

Ive been up for two nights in a row, trying to figure out how i can use this script with attachMovie(); . Im trying to create a border that auto resizes when MCs (basically just an image imported into an mc) load. This will be expoted as a projetor then burned onto a CD. I just need them to load from the library.

Any help would be greatly appreciated. Heres what i have so far:
space = 10;
photo_mc._alpha = 0;
MovieClip.prototype.loadPhoto = function(photo) {
this.attachMovie(photo);
_level0.photo_mc._alpha = 0;
_level0.onEnterFrame = function() {
var total = photo_mc.getBytesTotal(), loaded = photo_mc.getBytesLoaded();
if (total != 0 && total == loaded) {
var w = photo_mc._width+space;
var h = photo_mc._height+space;
border.resize(w, h);
delete _root.onEnterFrame;
}
};
};
MovieClip.prototype.resize = function(w, h) {
var speed = 4;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
if (Math.abs(this._width-w)<1) {
this._width = w;
this._height = h;
_root.photo_mc._x = this._x-this._width/2+space/2;
_root.photo_mc._y = this._y-this._height/2+space/2;
_root.photo_mc._alpha = 100;
delete this.onEnterFrame;
}
};
};
photo_mc.onEnterFrame = function() {
photo_mc.attachMovie(“image1”,1,1);
};
stop();
nextButton.onRelease = function() {
gotoAndStop(3);
};
previousButton.onRelease = function() {
gotoAndStop(35);
};