Get Width and Height from a properly load an external jpg

Hi all, I know you may have stumbled on this topic before however I just can’t seem to find the definite solution for this issue. When an image is fully loaded, I can’t seem to get the image’s ._width and ._height properties. It gives me 0.

I am dynamically loading external jpg images into a createEmptyMovieClip method. When this is happenning, I am constantly checking for its progress and when fully loaded I should be able to obtain the new width and height of the movieclip that contains the image.

[color=blue]var refMainImg = this.createEmptyMovieClip(“img”+counter, counter);[/color]
[color=blue]x.onEnterFrame = function()[/color][color=blue]{[/color]
[color=blue]refMainImg.loadMovie(“myImg.jpg”);[/color]
[color=blue]if(Math.round(refMainImg.[color=red]getBytesLoaded()[/color]/refMainImg.[color=red]getBytesTotal()[/color]) == 1)[/color]
[color=blue]refMainImg[color=darkorange]._x[/color] = refMainImg[color=darkorange]._width[/color]/2;[/color]
[color=blue]refMainImg[color=darkorange]._y[/color] = refMainImg[color=darkorange]._height[/color]/2;[/color]
[color=blue]}[/color]
[color=blue].[/color]
[color=blue].[/color]
[color=blue].[/color]
[color=blue]}[/color]

[color=black]Can someone provide me feedback or if possible know the solution of this problem? Many thanx![/color]