PDA

View Full Version : How do I center various sized loadmovied jpegs?



3dron
October 31st, 2002, 02:19 AM
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?

Thanks

Ron

andr.in
October 31st, 2002, 02:34 AM
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.

3dron
October 31st, 2002, 02:36 AM
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.


Ron

andr.in
October 31st, 2002, 03:29 AM
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... :*(

pom
October 31st, 2002, 05:22 AM
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:

3dron
October 31st, 2002, 01:13 PM
I guess this is my question.

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

Ron

pom
October 31st, 2002, 02:30 PM
It's the same... :)

3dron
October 31st, 2002, 03:35 PM
I tried

width = mc._width

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

How do I specify the jpg's width?

Ron

sbeener
October 31st, 2002, 07:02 PM
you have to wait for the jpg to load before finding its width.

ie.

loadMovie("greatPic.jpg",_root.picHolder);
_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.

3dron
November 1st, 2002, 02:11 AM
great, thanks guys!!!

Ron

3dron
November 1st, 2002, 04:00 AM
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)

Anyone?

Ron

pom
November 1st, 2002, 09:17 AM
Check the gallery tutorial, there's an ectionscripted preloader there. It might help you.

pom :)

3dron
November 1st, 2002, 01:22 PM
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.

Ron

upuaut
November 2nd, 2002, 03:38 AM
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

bt=_root.jpegMc.getBytesTotal();
bl=_root.jpegMc.getBytesLoaded();
if(bt=bl&&bt!=0){
gotoAndPlay(3);
}

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.