Set size of the loaded image in AS3.0
I'm loading images from xml file. I want the images to have standard width when they are displayed.
Here are the snippets of th开发者_运维问答e code that do the image processing:
var allThumbs:MovieClip = new MovieClip();
addChild(allThumbs);
allThumbs.width = 200;
allThumbs.height = 200;
galleryPane.source = allThumbs;
and here's the one that loades the images:
function loadTheThumbs() {
var c:Number = 0;
while(c < totalCats) {
var thumbLoader:Loader = new Loader();
var thumbRequest:URLRequest = new URLRequest(catImgList[c]);
thumbLoader.load(thumbRequest);
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, whenThumbLoaded);
function whenThumbLoaded(e:Event):void {
allThumbs.addChild(thumbLoader);
}
c++;
}
}
Everything worked cool before I inserted
allThumbs.width = 200;
allThumbs.height = 200;
this lines, where I wanted to resize the images before they show up in the ScrollPane.
I saw other threads here, but didn't help...
So maybe any ideas how should I do that?
Thanks in advance.
function whenThumbLoaded(e:Event):void {
allThumbs.addChild(thumbLoader);
}
you might want to set up the position of the images and the scale here
function whenThumbLoaded(e:Event):void {
thumbloader.x = c * 220;
thumbloader.y = 0;
thumbloader.width = 200;
thumbloader.height = 200;
allThumbs.addChild(thumbLoader);
}
精彩评论