# Trouble getting/using \_width/\_height of a loaded jpeg

**URL:** <https://forum.kirupa.com/t/trouble-getting-using--width--height-of-a-loaded-jpeg/115305>\
**Category:** Uncategorized\
**Created:** [July 7, 2004, 4:37pm UTC](https://forum.kirupa.com/t/trouble-getting-using--width--height-of-a-loaded-jpeg/115305 "2004-07-07T16:37:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariachi77](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@mariachi77](https://forum.kirupa.com/u/mariachi77)\
**Post date:** [July 7, 2004, 4:37pm UTC](https://forum.kirupa.com/t/trouble-getting-using--width--height-of-a-loaded-jpeg/115305/1 "2004-07-07T16:37:45Z")

</div>

Hi,

I’m having trouble getting the \_width & \_height of a jpeg loaded using loadMovie.

I’m trying to reposition it (pseudo-registration point) for rotation in a container movie clip.

If I use hard-coded numbers, it works fine. However, if I try to position it based on its \_width and \_height properties, it’s no go… in fact, it doesn’t even show up on stage.

Are there problems getting those properties from loadMovie clips?

---

<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:** [July 7, 2004, 5:36pm UTC](https://forum.kirupa.com/t/trouble-getting-using--width--height-of-a-loaded-jpeg/115305/2 "2004-07-07T17:36:50Z")

</div>

It’s the same idea as assigning an event handler to the loaded picture. Check number 3 on the following post:  
[http://www.kirupaforum.com/forums/showthread.php?t=61309](http://www.kirupaforum.com/forums/showthread.php?t=61309)

---

<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:** [July 7, 2004, 5:57pm UTC](https://forum.kirupa.com/t/trouble-getting-using--width--height-of-a-loaded-jpeg/115305/3 "2004-07-07T17:57:56Z")

</div>

In that thread, you mention that you can’t assign event handlers (or access these properties) until the clip is done loading. However, that’s precisely where I’m trying to access the clip’s properties.

In the container clip, I’ve got an onEnterFrame function which checks to see that it’s 100% loaded and then it attempts to set the image’s position (based on it’s measurements). Perhaps I’m trying to reference the clip incorrectly?

Have a look:

\<!-- an excerptfrom the outer clip’s onEnterFrame function  
\<!-- “jpg” is the name of the loadMovie clip

```
                  if(this.percent.text == "100") {
                      this.percent.text = "";
                      
                      var w = this.jpg._width/2;// didn't work
                      var h = this.jpg._height/2;//didn't work
                      //this.jpg._x = -(this.jpg._width/2);//didn't work
                      //this.jpg._y = -(this.jpg._height/2);//didn't work

```

[//this.jpg](https://this.jpg).\_x = -w;//didn’t work  
[//this.jpg](https://this.jpg).\_y = -h;//didn’t work  
with (this.jpg){  
\_x = -60;//static position I gave  
\_y = -60;//static position I gave  
\_yscale = 24;  
\_xscale = 24;  
}

```
                      delete this.onEnterFrame;
                  }

```

As you can see, I’ve tried a few ways to reference the clip, thinking that’s the problem. How would you write this code?

Cheers,

Mike

> [@claudio](#):
>
> It’s the same idea as assigning an event handler to the loaded picture. Check number 3 on the following post:  
> [http://www.kirupaforum.com/forums/showthread.php?t=61309](http://www.kirupaforum.com/forums/showthread.php?t=61309)

---

<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:** [July 7, 2004, 6:09pm UTC](https://forum.kirupa.com/t/trouble-getting-using--width--height-of-a-loaded-jpeg/115305/4 "2004-07-07T18:09:44Z")

</div>

This will fail:

```auto
createEmptyMovieClip("container_mc", 1);
container_mc.loadMovie("picture.jpg");
trace(container_mc._height);//will return 0
trace(container_mc._width);//will return 0

```

This will work:

```auto
createEmptyMovieClip("container_mc", 1);
createEmptyMovieClip("loader_mc", 2);
container_mc.loadMovie("picture.jpg");
loader_mc.onEnterFrame = function() {
	var t = container_mc.getBytesTotal();
	var l = container_mc.getBytesLoaded();
	if (t && l == t) {
		trace(container_mc._height);
		trace(container_mc._width);
		this.removeMovieClip();
	}
};

```
