Tuesday, July 18, 2006
I'm sooooo close to completing my upgraded Threadless widget but one thing has me stumped! I'm loading an image from an RSS feed, then onLoadInit I'm resizing the containing mc to the correct dimensions for my widget, then I'm drawing the mc to the bitmap object. Sounds good so far right? except the original size image gets drawn to the bitmap object even though there is a delay before the .draw method is called?! I think I'll call it a night and think about this one tomorrow, if anyone has any suggestions please leave me a comment and save me from a day of headscratching!Jon 10:32 PM Permalink
Comments:
Yeah, the draw function always draws an untransformed version of the object you are drawing - no rotation, scaling, translation, coloring. That's what the second param is for. Just pass in a matrix that scales it to thre correct size.
Not sure if this helps - I found a different problem from Keith's with scaling loaded images and found I had to wait a few ms after loading an image:
class ImageForm extends MovieClip{
/* Placeholder for the returned value from setInterval
*/
private var mScaleInterval = false;
/*
.....
*/
private var mScaleInterval = false;
/*
implement our MCL listener function
*/
function onLoadComplete(pClip:MovieClip, httpStatus:Number) {
Log.it("onLoadComplete " + pClip._width + ", " + pClip._height + ", " + pClip);
mLoader.removeListener(this);
//We wait for a little while here because we cannot access the image properties otherwise...
this.mScaleInterval = setInterval(this, "loadedImageWait", 100);
}
/*
Clean up after the image has loaded
*/
private function loadedImageWait() {
//resizeImage()... clearInterval(this.mScaleInterval);
}
} //end of class
Use the containing movieclips transformation matrix, to make it appear exactly as it does inside the container mc:
bmp.draw(containerMc,containerMc.transform.matrix)
Fantastic, thanks guys I wasn't sure exactly how the transformation matrix came into it.


