Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

I have this source in Adobe Flash CS6 (AS3).

var loader:Loader =new Loader();
imageViewer_mc.addChild(loader);     
loader.x=65;
loader.y=50;
loader.load(new URLRequest("image.jpg"));

image.jpg size is 200px X 400px and viewing nice in pages. But when I replace it with 600px X 1200px Image, It doesn't have previous size. I know that something is wrong with my code; But I don't know where is it.

My clear question: How can I load different images in a loader with same size?

( Can I fit images to their container, imageViewer_mc?)

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Your problem is that, even though you are adding the loader to the parent imageViewer_mc movieclip, the loader will not have the same size as its parent.

You can set the width and height of the loaded image as follows:

var loader:Loader =new Loader();
imageViewer_mc.addChild(loader);     
loader.load(new URLRequest("image2.jpg"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(){
    loader.content.width = 200;
    loader.content.height = 400;
});

A graphic-based solution, to a different effect, would be to simply crop the image with a layer mask. (New Layer, Right-Click Mask, Unlock, Draw shape to crop within it).

share|improve this answer

In ActionScript 3 (Flash CS4 OR higher), its better to use UILoader component instead of MovieClip.

For loading images you we use:

imageViewer_mc.source="image.jpg";

We can set objects properties visual. This way fits image to loader and resizes file with proportions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.