1 Reply Latest reply on Jun 20, 2007 11:16 PM by jpwrunyan

    get width and height of a dynamically loaded image once it's done loading?!

      hello : :

      well... i'm taking my first shots at flex after programming in flash for a year now. it's been fun and i've been picking up on things pretty well (or so i think), but i come across something today that i used to be able to do in my as2 programming and don't know how to do in as3...

      in flex, i'm loading an image into an image control (by using "myImgControl.load(urlString)"). i have a "complete" parameter on the image control that calls a function just fine after the image is loaded, but if i try and check the hight and width of the loaded image once it loads, it comes back as zero. how can i get the height and width of the image after it's loaded?!

      in flash/as2 i used to do this little trick/work-around i found in a forum (kirupa.com, i think) to find out the width and height once the loaded image listener checked the loading process and came back "complete"... in the code below, "imgLoader" is the movieClip the image was loaded using imgLoaderListener.loadClip(urlString, imgLoader).


      iTot = imgLoader.getBytesTotal();
      iLoad = imgLoader.getBytesLoaded();
      if (iLoad == iTot && iTot > 4) {
      imgH = imgLoader._height;
      imgW = imgLoader._width;

      that all make sense?!

      basically, it's as simple as this: i need to find something similar to the above for as3 that will tell me the width and height of a dynamically loaded image after it's done loading...

      so there ya have it. i appreciate any help any of you can throw my way! thank you so much for even reading this!

      : : michael