Trouble getting/using _width/_height of a loaded jpeg

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?

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

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._x = -w;//didn’t work
//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

This will fail:

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:

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();
	}
};