# Loading image problem, please help

**URL:** <https://forum.kirupa.com/t/loading-image-problem-please-help/27384>\
**Category:** flash\
**Created:** [August 1, 2003, 6:51pm UTC](https://forum.kirupa.com/t/loading-image-problem-please-help/27384 "2003-08-01T18:51:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![7of9](https://avatars.discourse-cdn.com/v4/letter/7/c89c15/32.png) [@7of9](https://forum.kirupa.com/u/7of9)\
**Post date:** [August 1, 2003, 6:51pm UTC](https://forum.kirupa.com/t/loading-image-problem-please-help/27384/1 "2003-08-01T18:51:26Z")

</div>

The below code works, no errors but doesn’t work like I want it too.

For example: Look at the following code:  
[AS]trace(img\_mc.\_width); //produces a value  
img\_mc.ResizeImage(22,22);[/AS]  
This is what I don’t get: img\_mc Mc doesn’t call my prototype  
for some reason. I know the prototype works because if I call  
the prototype with another Mc like ThumbnailMc it works.

Apparently img\_mc losses itself as a Mc but generates a \_width  
value prior to calling the prototype. Don’t know why, help.  
[AS]MovieClip.prototype.ResizeImage = function(wMax, hMax) {  
if (this.\_width\>wMax || this.\_height\>hMax) {  
trace(“ss”);  
//which dimension is the most oversized  
wDiff = this.\_width-wMax;  
hDiff = this.\_height-hMax;  
//calculate ratio  
if (wDiff\>hDiff) {  
ratio = (wMax/this.\_width)_100;  
} else {  
ratio = (hMax/this.\_height)100;  
}  
} else {  
//if image doesn’t need to be resized set ratio to 100  
ratio = 100;  
}  
this.\_xscale = this.\_yscale=ratio;  
};  
var McHolder = \_root.createEmptyMovieClip(“Container”, 550);  
Mc = McHolder.attachMovie(“ColorMc1”, “ColorMc1”, 45);  
Mc.\_x = 74i;  
Mc.\_y = 39_j;  
ThumbNailMc = \_root.Container.ColorMc1;  
img\_mc = ThumbNailMc.createEmptyMovieClip(“PicContainer”, 25);  
img\_mc.loadMovie(“[http://mysite/photos/image.jpg](http://mysite/photos/image.jpg)”);  
Mc.onEnterFrame = function() {  
var bytes\_loaded = Math.round(img\_mc.getBytesLoaded());  
var bytes\_total = Math.round(img\_mc.getBytesTotal());  
var getPercent = bytes\_loaded/bytes\_total;  
if (bytes\_loaded\>1 && bytes\_loaded\>bytes\_total-10 && img\_mc.\_width\>0 && getPercent\>=1) {  
trace(img\_mc.\_width);  
img\_mc.ResizeImage(22, 22);  
delete this.onEnterFrame;  
}  
};  
stop();[/AS]
