Jump to content


Image Loader & Image Size

Recommended Posts



I have a sprite which I'm loading an image into:


  imageBox.graphics.drawRect(0, 0, 100, 100);




var pageImageLoader:LoaderMax = new LoaderMax({name:"mainImageLoader"});
   pageImageLoader.append( new ImageLoader(pageImage, {name:"mainImage", container:imageBox, scaleMode:"proportionalInside"}) );


After I have completed the load I position and size the sprite:


imageBox.x = 710;
   imageBox.y = 30;
   imageBox.width = 465;
   imageBox.height = 665;


When the sprite is created initially it's width and height are set to 100. The result is the loaded image is scaled massively. If I set the sprites width and height to the same vales as I do later (465 665) the image displays correctly. My problem is that depending upon a conditional earlier on, the size of the final sprite can be any of 7 different widths and/or heights, and I need the image to display correctly.


I've tried loading the image last, setting the sprite to be 0,0 etc.


Any ideas? Thanks.

Link to comment
Share on other sites

It sounds like you're misunderstanding the sizing functionality that's built into the ImageLoader - it does NOT resize itself according to its container's size. It resizes according to the width/height you set on the ImageLoader itself.



//this defines a scaleMode but no width/height to scale within
new ImageLoader(pageImage, {name:"mainImage", container:imageBox, scaleMode:"proportionalInside"});



//this defines a scaleMode and a width/height to scale within
new ImageLoader(pageImage, {name:"mainImage", container:imageBox, scaleMode:"proportionalInside", width:100, height:100});


So you should be able to solve your problem by simply setting the appropriate width/height on your ImageLoader instance. If you need to control that size later, you can set the fitWidth and fitHeight properties of the ImageLoader's ContentDisplay object (myImageLoader.content.fitWidth = 100 for example)

Link to comment
Share on other sites

Ahh, ok, thanks, that makes sense. Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.