# How do I center various sized loadmovied jpegs?

**URL:** https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450
**Category:** flash
**Created:** [October 31, 2002, 7:19am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450 "2002-10-31T07:19:42Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![3dron](https://avatars.discourse-cdn.com/v4/letter/3/2acd7d/32.png) [@3dron](https://forum.kirupa.com/u/3dron)
#### Post date: [October 31, 2002, 7:19am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/1 "2002-10-31T07:19:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 7:34am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/2 "2002-10-31T07:34:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 7:36am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/3 "2002-10-31T07:36:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 8:29am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/4 "2002-10-31T08:29:31Z")

</div>

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… :\*(

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 10:22am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/5 "2002-10-31T10:22:30Z")

</div>

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:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 6:13pm UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/6 "2002-10-31T18:13:21Z")

</div>

I guess this is my question.

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

Ron

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 7:30pm UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/7 "2002-10-31T19:30:32Z")

</div>

It’s the same… 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 31, 2002, 8:35pm UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/8 "2002-10-31T20:35:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 1, 2002, 12:02am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/9 "2002-11-01T00:02:17Z")

</div>

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

ie.

```auto

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 1, 2002, 7:11am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/10 "2002-11-01T07:11:40Z")

</div>

great, thanks guys!!!

Ron

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 1, 2002, 9:00am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/11 "2002-11-01T09:00:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 1, 2002, 2:17pm UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/12 "2002-11-01T14:17:40Z")

</div>

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

pom 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 1, 2002, 6:22pm UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/13 "2002-11-01T18:22:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 2, 2002, 8:38am UTC](https://forum.kirupa.com/t/how-do-i-center-various-sized-loadmovied-jpegs/7450/14 "2002-11-02T08:38:23Z")

</div>

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.
