I have a movieClip (empty) which is used has a placeholder to load external images. I need to fix the max size of that placeHolder to 367367 values, so that if the image has 500400 it will shrink to 367*294 when loaded…And so i used the following code at the placeHolder:
onClipEvent (data) {
loaded = 1;
var maxWidth = 367;
var maxHeight = 367;
if (this._width > maxWidth || this._height > maxHeight)
{
var scaleFactor = this._width > this._height ? maxWidth / this._width : maxHeight / this._height;
this._width = Math.floor (this._width * scaleFactor);
this._height = Math.floor (this._height * scaleFactor);
}
if (this._height > maxHeight)
{
var scaleFactor = maxHeight / this._height;
this._width = Math.floor (this._width * scaleFactor);
this._height = Math.floor (this._height * scaleFactor);
}
}
The problem is that this only works the first time i load an image. After that the images appear much smaller … Can anyone help with the code please?
Thks.