How do I center various sized loadmovied jpegs?

I need to figure out a way to center loaded jpegs within an mc.

By default I know they load with their topic corner aligned with the orgin of the mc.

Is there a way to keep the origin at the center, and have loadmovie align the jpeg center?

Or how can I obtain the images dimensions so I can apply the proper x-y transforms to get it where I want?



If you load a bunch of stuff in one mc then the best thing to do is move the mc to a better position so when the stuff is loaded they will be in the right position.

I do need the image centered within the mc, because when a different mc loads into this mc it may have different dimensions, then it to needs to be centered.

It is a very particular thing I am trying to do.


humm… yes…
another option would be if something nah… nonono what the heck am I saying here…
maybe somebody else can help ya with that… :*(

You have to preload your jpeg, wait until it’s downloaded completely and then you can access it’s properties. I know it’s true for the width and height, it should be the same for the position and everything else.

pom :asian:

I guess this is my question.

I know mc._width, but how do I get _width of jpeg?


It’s the same… :slight_smile:

I tried

width = mc._width

But this only returned the same width of the original mc.

How do I specify the jpg’s width?


you have to wait for the jpg to load before finding its width.


_root.picHolder._x = _root.picHolder._width/2;
_root.picHolder._y = _root.picHolder._height/2;

that won’t work because greatPic.jpg hasn’t had time to load in before the size is grabbed.

one solution is to build a preloader which will position the movie once it has loaded.

great, thanks guys!!!


Well guys, I spent the last 2 hours trying to build a preloader for a jpg.

Couldn’t figure it out.

jpegMc.getBytesTotal only return value after the jpeg has loaded.

so I couldn’t divide getBytesLoaded by Total to check for 100% before trying to grab width and height.

Call getBytesTotal immediately after loadmovie returns 0.

But if I place getBytesTotal somehwere down the timeline it give proper byte count. (Telling me getbytes only available after load)



Check the gallery tutorial, there’s an ectionscripted preloader there. It might help you.

pom :slight_smile:

part of my 2 hour adventure was looking through all of these, and non applied to my situation.

here is what I have:

I have a number of thumbnails created with attachMovie based on the number of file names in an array.

In a “for” statement I have mc’s created and jpegs loaded into them.

So I can’t use preloader that check the _root movie’s load status.
I need the load status of these individual jpegs so they can be centered into the attachMovie generated mc’s.


Well I don’t know about your specific problem (because with preloaders there are many) but I can tell you that EVERYTHING returns 0 as bytesTotal when it first loads, even the _root. I use an && statement with my if statement to make sure that it doesn’t continue when both the bytes loaded and the bytes total read 0.

something like


Now you’re saying that the totalBytes doesn’t show up as anything but 0 until the whole thing loads. That SHOULD not be the case. If it is, then there’s some other problem. Could be addressing.