var preload = holder.createEmptyMovieClip("preload", 1);
holder._visible = false;
var image = ct.createEmptyMovieClip("image", 1);
ct._alpha = 0;
loader._visible = false;
var path = "";
function loadImg(path) {
_path = path;
preload.loadMovie(path);
loader._x = int(-bgnd._width / 2);
loader._y = int(-bgnd._height / 2);
loader.setPerc(0);
holder.onEnterFrame = function() {
var cur = preload.getBytesLoaded();
var max = preload.getBytesTotal();
if (cur > 10 && max > 10) {
var p = cur * 100 / max;
loader._visible = true;
loader.setPerc(p);
if (p >= 100) {
delete holder.onEnterFrame;
loader._visible = false;
hideImg();
}
}
}
}
function hideImg() {
ct.onEnterFrame = function() {
this._alpha += (0 - this._alpha) / 3;
if (this._alpha <= 1) {
this._alpha = 0;
delete this.onEnterFrame;
swapImg();
}
}
}
function swapImg() {
image.loadMovie(_path);
reScale(preload._width, preload._height);
}
function reScale(w, h) {
image._x = -w / 2;
image._y = -h / 2;
w += 0;
h += 0;
this.onEnterFrame = function() {
bgnd._width += (w - bgnd._width) / 2;
bgnd._height += (h - bgnd._height) / 2;
shadow._width = bgnd._width;
shadow._height = bgnd._height;
if (Math.abs(w - bgnd._width) < 1 && Math.abs(h - bgnd._height) < 1) {
bgnd._width = w;
bgnd._height = h;
shadow._width = bgnd._width;
shadow._height = bgnd._height;
loader._x = int(-bgnd._width / 2);
loader._y = int(-bgnd._height / 2);
delete this.onEnterFrame;
showImg();
}
}
}
function showImg() {
ct.onEnterFrame = function() {
this._alpha += (100 - this._alpha) / 3;
if (this._alpha >= 99) {
this._alpha = 100;
delete this.onEnterFrame;
}
}
}