Ive used this code to resize pictures that are loaded in an movieClip instance but when it reloads a new picture it does not update the thisHeigt, it just uses the smallest value of the loaded picture, my question how do i update this value?
//variable declarations to hold the values
var thisWidth:Number;
var thisHeight:Number;
var maximumHeight:Number;//height to which movieclip to be resized
var maximumWidth:Number;//width to which movieclip to be resized
var oldx:Number;
var oldy:Number;
var ratio:Number;
var mclis:Object = new Object();//An object that listens for a callback notification from the MovieClipLoader event handlers.
mclis.onLoadInit = function(target_mc:MovieClip) {//Invoked when the actions on the first frame of the loaded clip have been executed
thisHeight = target_mc._height;//loaded movieclip height
maximumHeight = 300;
thisWidth = target_mc._width;//loaded movieclip width
maximumWidth = 300;
ratio = thisHeight/thisWidth;//calculation ratio to which resize takes place
if (thisWidth>maximumWidth) {
thisWidth = maximumWidth;
thisHeight = Math.round(thisWidth*ratio);
}
if (thisHeight>maximumHeight) {
thisHeight = maximumHeight;
thisWidth = Math.round(thisHeight/ratio);
}
target_mc._width = thisWidth;//applying new width
target_mc._height = thisHeight;//applying new height
};
var mcl:MovieClipLoader = new MovieClipLoader();//MovieClipLoader class lets you implement listener callbacks that provide status information while SWF, JPEG, GIF, and PNG files are being loaded into movie clips.
mcl.addListener(mclis);//add the object as listener for event handlers
function loadClip(){
mcl.loadClip("bild/"+bildNode+".jpg", target_mc);//You can use the loadClip() method to load one or more files into a single movie clip or level;
}
//Create listener object.
var DGListener:Object = new Object();
DGListener.change = function() {
var cellID:String = theList.selectedItem.LatinsktNamn;
var info:String = "<trad><info>" + cellID + "</info></trad>";
var infoXMLskickad:XML = new XML(info);
infoXMLskickad.ignoreWhite = true;
infoXMLskickad.sendAndLoad("http://localhost/info.php?", infoXMLMot);
infoXMLMot.onLoad = function(){
var infoNode = this.firstChild.firstChild.firstChild.firstChild.nodeValue;
_global.bildNode = this.firstChild.firstChild.firstChild.nextSibling.firstChild.nodeValue;
DSInfo.addItem({info:infoNode});
loadClip();
}
}