How do I get the width of a scaled bitmap image, 
In my example, it's returning the width of the unscaled width,
ie. I have an image that's portrait aspect ratio, when put into a
landscape oriented box, the width is the size of the box, not the smaller 
scaled bitmap.

Is there another property that I can check??

 <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"; 
                           xmlns:s="library://ns.adobe.com/flex/spark" 
                           xmlns:mx="library://ns.adobe.com/flex/mx" 
                           xmlns:local="*"  >
        <s:layout>
                <s:VerticalLayout  horizontalAlign="center" />
        </s:layout>
        <fx:Script>
                <![CDATA[
                        private function loadImg(event:Event):void {
                                var RedImage:BitmapData = new 
BitmapData(200,300,false,0xff5000);
                                myImage.source = RedImage;
                        }
                ]]>
        </fx:Script>
        
        <s:HGroup width="100%" height="100%" verticalAlign="bottom" >
                <local:CustomImage id="myImage" width="100%" height="100%" 
scaleMode="letterbox" />
        </s:HGroup>
        <s:Button label="Load Image" click="loadImg(event)" />
</s:Application>

package
{
        import spark.components.Image;
        
        public class CustomImage extends Image
        {
                public function CustomImage()
                {
                        super();
                }

                override protected function updateDisplayList (unscaledWidth : 
Number, unscaledHeight : Number) : void
                {
                        super.updateDisplayList (unscaledWidth, unscaledHeight);
                        trace('width = '+String(unscaledWidth) + ', height =' + 
String(unscaledHeight) );
                }
        }
}



Reply via email to