0 Replies Latest reply on Jan 18, 2007 8:38 AM by Matthew_Soldo

    Issue binding to width of image loaded at runtime

      Hi all,

      I'm having an issue with binding. I have the following situation. There is one image loaded at runtime (via .load() method) based on a url located in an external xml file. This image's dimensions are unknown until it is loaded (the dimensions are listed in the xml file). This image's scalex and scaley values are bound to the value of an hslider. There is a second image which is embedded into the application. It needs to be scaled such that it is just slightly larger than the first image, but with the same exact aspect ratio.

      I tried to bind this second image width/height to the first images width/height (see below), but this yield unpredictable results: when the slider value is changed the first image scales correctly but the second image usually scales incorrectly or not at all (although sometimes it does work). Is there a workaround for this?

      One thought I had was to create a binding in the actionscript code at the time that the first image is loaded based upon its actual height and width (ie source of binding is firstimage.originalheight * slider.value + constant destination is secondimage.height).

      <mx:Image id="firstImage" source="" horizontalCenter="0" verticalCenter="0"/>
      <mx:Image id="secondImage" source="{matCutoutClass}" verticalAlign="middle" horizontalAlign="center" horizontalCenter="0" verticalCenter="0" autoLoad="true" alpha="1" scaleContent="true" maintainAspectRatio="false"/>
      <mx:HSlider id="photoSizeSlider" minimum=".3" maximum="1" value=".5" liveDragging="true" allowTrackClick="true"/>
      <mx:Binding source="photoSizeSlider.value" destination="firstImage.scaleX"/>
      <mx:Binding source="photoSizeSlider.value" destination="firstImage.scaleY"/>
      <mx:Binding source="activePhoto.height+14" destination="secondImage.height"/>
      <mx:Binding source="activePhoto.width+14" destination="secondImage.width/>