flash actionscript:
Hi,
I have a script where I load and scale different images in a single movie clip
but it does not work correctly. The dimensions seem to "stay in memory" so
every new image I load gets scaled according to the first scaling value. The
scaling value stays the same until I load a larger image, then it gets modified
but remains at the scale of the larger image.
Any ideas on what the problem is? I am attaching a sample of my code to this
message.
Thank you,
-ez
public void someInitFunction():Void {
// set up main image loading handler
mainLoadListener = new Object();
mainLoadListener.onLoadInit = function(targetMC:MovieClip) {
GlobalController.contentController.currentContent.scaleImage(targetMC);
}
mainLoader = new MovieClipLoader();
mainLoader.addListener(mainLoadListener);
// set up main image placeholder
imgMC = contentMC.createEmptyMovieClip("selectedImage",
contentMC.getNextHighestDepth());
placeImage(currSlide);
}
/** places the selected image in the placeholder **/
public function placeImage(imgIndex:Number):Void {
mainLoader.loadClip(slides[imgIndex].path, imgMC);
}
/** scales and places the selected image **/
public function scaleImage(imageMC:MovieClip):Void {
trace("1) imgWidth:"+imageMC._width+" maxWidth:"+imgMaxWidth+"
imgHeight:"+imageMC._height+" maxHeight:"+imgMaxHeight);
// scale the larger of the 2 dimensions, only if it is greater than the
allowable value
if (imageMC._width > imgMaxWidth) {
trace("scaling width");
imageMC._width = imgMaxWidth;
imageMC._yscale = imageMC._xscale;
}
if (imageMC._height > imgMaxHeight) {
trace("scaling height");
imageMC._height= imgMaxHeight;
imageMC._xscale = imageMC._yscale;
}
trace("2) imgWidth:"+imageMC._width+" maxWidth:"+imgMaxWidth+"
imgHeight:"+imageMC._height+" maxHeight:"+imgMaxHeight);
// place the image in the center of the placeholder
imageMC._x = (imgMaxWidth-imageMC._width)/2;
imageMC._y = (imgMaxHeight-imageMC._height)/2;
}