Ok, aquí un par de turinas que cargan la imágen y la reescalan, las hice para esta galería
http://www.flash-db.com/Tutorials/Gallery/, por lo que hay cosas que no vienen a cuento, pero lo principal está ahí. Son un par de métodos de la clase holder
Código :
/**
* Load big images
* @param who name of the image
*/
public function loadImage (who : String) : Void {
//Create container just once for loading big photos
if(!foto) foto = this._parent.createEmptyMovieClip("foto", 1)
foto.loadMovie ("photos/orig/"+ who)
foto._visible = false
preload._visible = true
//preloading
this.onEnterFrame = function ()
{
var perc = Math.round(foto.getBytesLoaded()/foto.getBytesTotal()*100);
preload.barra._width = perc
foto._visible = false
if (perc >= 100 && foto.getBytesLoaded () > 1 && foto._width > 1)
{
delete this.onEnterFrame
preload._visible = false
var dim = checkSize(foto._width, foto._height)
resize (dim.w, dim.h)
//assign contextMenu
foto.menu = cmMenu
//Saves image name for contextMenu
foto.image = who
//enables now
}
}
}
/**
* Checkif the size of image overpass max limits
* @param w width of the image
* @param h heigth of the image
*/
private function checkSize(w:Number, h:Number):Object{
if(h<=maxHeight && w<=maxWidth) {
return {h:h, w:w}
} else { //recalculate dimensions, overpass boundaries
var orientation =(w>h)?"w" : "h"
if(orientation=="h"){
var per = int((maxHeight*100)/h)
var newWidth = int((w*per)/100)
return {h:maxHeight, w:newWidth}
} else {
var per = int((maxWidth*100)/w)
var newHeight = int((h*per)/100)
return {h:newHeight, w:maxWidth}
}
}
}
Jorge