STRESS! Resizing imported jpegs

Hi everybody,

I am VERY new to actionscripting and have got myself into a bit of a muddle. I am trying to import a jpeg image into an empty movie clip and then resize the image. I can scale it, and position it but I can’t resize it.

Somebody suggested creating a movieclip in Flash first and giving it an instance name. Then use loadMovie to place the jpeg into that movieclip. This did work and allowed me to resize it but only the movieclip would be resized which in turn resized the image proportionally. I still couldn’t specify exact dimensions of the image - only the movieclip. I hope this makes sense… I think I’ve lost myself!!

Any ideas of help would be greatly appreciated.

Many thanks in advance

Brasso

I can scale it, and position it but I can’t resize it.

What’s the difference between Scale and Resize?

I’d love to help too, but I dont get the question

When scaling a movieclip you use _xscale and _yscale and specify them as percentages.

I want to use _width and _height and give the movieclip exact dimensions in pixels…

If you are loading the pic into a container, can’t you just modify the width and height of the container MC once you know the pic has fully loaded?

That’s what I thought but it doesn’t appear to be working! Here is my code:


this.createEmptyMovieClip(“cab”,-100000)
cab.onData=function(){
trace(“hey”)
}
cab.onLoad=function(){
trace(“loaded”)
cab._x=10;
cab._y=80;

}
cab.loadMovie(“images/test.jpg”);

Like I said, I can position it and scale it but when I try and resize it using cab._width and cab._height the image just disappears!!!

this.createEmptyMovieClip("cab", 1);
cab.loadMovie("images/test.jpg");
tmp = cab.createEmptyMovieClip("temp", 100);
tmp.onEnterFrame = function() {
	t = cab.getBytesTotal();
	l = cab.getBytesLoaded();
	if (t == l && t != 0 && cab._width>0 && cab._height>0) {
		cab._x = 10;
		cab._y = 80;
		trace(cab._width+" + "+cab._height);
		delete this.onEnterFrame;
	}
};

Like Ordinathorreur has said;)

scotty(-:

Hi Scotty,

Thanks for the reply. However I’m still having problems. There seems to be a problem with the IF statement. It never returns true. Should there be some sort of loop to test how much of the movieclip has loaded?

Cheers

Brasso

Can you post your fla?

scotty(-:

I always have trouble testing getBytesTotal against getBytesLoaded with jpeg loads as well, so in Scotty’s code, I would just leave out the t==l. Since the width and height aren’t set till it is loaded anyway, their checks should be sufficient. Try

if (t == l && t != 0 && cab._width>0 && cab._height>0) {