|
-
imageLoader resize fadeIn problems :(
Hello!
I've been working on this simple script. It loads an image, grabs the size of the image, resizes a frame to the image size, and fades in the image.
The problem is the fading. It's not working correctly, and I can't figure out the problem. It fades in the first time, then after that goes goofy and appears before the frame resizes, and causes downright badness.
The code is below.
Here is a link to the .fla.
To chk out the swf in action, click here.
Any help would be great! Thanks alot in advance!
code:
MovieClip.prototype.preload = function(image, barWidth, imgWidth, imgHeight) {
// Set variables
var barWidth = barWidth == undefined ? 100 : barWidth;
var imgWidth = imgWidth == undefined ? 0 : imgWidth;
var imgHeight = imgHeight == undefined ? 0 : imgHeight;
// Create mc's
this.createEmptyMovieClip("PH_mc", 0);
this.createEmptyMovieClip("updater_mc", 1);
_root.createEmptyMovieClip("bar_mc", 2);
//this.bar_mc._y = _root.newBar_y;
_root.imageLoad_container._alpha = 100;
// Scale bar
// Make preloader bar
with (_root.bar_mc) {
beginFill(0xE2EDF1, 100);
lineTo(barWidth, 0);
lineTo(barWidth, 1);
lineTo(0, 1);
lineTo(0, 0);
}
// Set bar mc dimensions position
_root.bar_mc._height = 5;
_root.bar_mc._xscale = 1;
_root.bar_mc._x = (20+(_root.round_mc._width/2)-30);
_root.bar_mc._y = (10+(_root.round_mc._height/2)-3);
// Set bar mc and text mc positions
//if (imgWidth != 0) {
//this.bar_mc._x = 0;
//}
// Load image
this.PH_mc.loadMovie(image);
// Get updater running
this.updater_mc.onEnterFrame = function() {
this.Loaded = this._parent.PH_mc.getBytesLoaded();
this.Total = this._parent.PH_mc.getBytesTotal();
this.Percent = Math.ceil((this.Loaded/this.Total)*100);
if (_root.bar_mc._xscale < 99) {
this.Percent = this.Total == 0 ? 0 : this.Percent;
//this._parent.PH_mc._alpha = 100;
_root.imageLoad_container._alpha = 0;
_root.bar_mc._xscale = this.Percent;
//this._parent.bar_mc.tween(["_xscale"], [this.Percent], 0.4, "linear", 0);
//trace(_root.imageLoad_container._width);
//trace(_root.imageLoad_container._height);
//trace(this.Percent+" %");
} else {
_root.bar_mc._x = 0;
delete this.onEnterFrame;
_root.loadResize(_root.imageLoad_container._width+ 5, _root.imageLoad_container._height+5);
_root.bar_mc.removeMovieClip();
this._parent.updater_mc.removeMovieClip();
_root.imageLoad_container._alpha = 0;
_root.imageLoad_container.alphaTo(100, 1, "easeoutquint", 0.5);
//this._parent.PH_mc._alpha = 100;
//_root.tempImage.loadMovie(image);
//_root.imageLoad_container._alpha = 0;
this.removeMovieClip();
}
};
};
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|