6 Replies Latest reply on Jul 1, 2011 8:57 AM by JCVD-13

    <s:BitmapImage get image scaled size and position after it loaded and scaled

    Nimrod_Sion

      I am try to know the dimensions of the uploaded image into <s:BitmapImage without success.

       

      The data coming back to me are isthe real image size and not size after it was scaled to fit the component size.

       

      I can see that the image scaled down and fit to the maxWidth, but I can't get the actual/real scaled width from the BitmapIMage properties.

       

      I tried:

       

      <s:BitmapImage id="mainBitMap"  ready="mainBitMap_readyHandler(event)" complete="bitmapimage1_completeHandler(event)" source="{data.Thumbnail.URL}" maxHeight="250" maxWidth="250" scaleMode="letterbox"/>

       

       

       

      protected function bitmapimage1_completeHandler(event:Event):void

      {

       

       

      trace("----------------------Start-----------------------");

       

      trace("mainBitMap.bitmapData.width" + mainBitMap.bitmapData.width);

       

      trace("mainBitMap.width" + mainBitMap.width);

       

      trace("mainBitMap.measuredWidth" + mainBitMap.measuredWidth);

       

      trace("mainBitMap.displayObject.width" + mainBitMap.displayObject.width);

       

      trace("mainBitMap.explicitWidth.width" + mainBitMap.explicitWidth);

       

      trace("mainBitMap.preliminaryWidth" + mainBitMap.preliminaryWidth);

       

      trace("mainBitMap.sourceWidth" + mainBitMap.sourceWidth);

       

      trace("-----------------------End------------------------");

       

      }

       

       

       

      Result:

      ----------------------Start-----------------------

      mainBitMap.bitmapData.width=435

      mainBitMap.width=0

      mainBitMap.measuredWidth=0

      mainBitMap.displayObject.width=0

      mainBitMap.explicitWidth.width=NaN

      mainBitMap.preliminaryWidth=NaN

      mainBitMap.displayObject.preliminaryWidth=435

      -----------------------End------------------------

       

      Thanks,

      Nimrod.