I'm looking for the best way to get a flex 4 image object to resize and horizontally center whenever its parent container (a custom component based on group) resizes. I cannot set horizontalCenter="0" to accomplish the image centering because I use a move transition to "slide" the image in and out of view.
I'm externally setting the image source in the component. Here is a simplified example of my component code that only addresses resizing the image.
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" >
<fx:Script>
<![CDATA[
public function assignImage(imgUrl:String):void
{
imgA.source = imgUrl;
imgA.visible = true;
}
override protected function updateDisplayList(w:Number,h:Number):void
{
imgA.width = w;
imgA.height = h;
super.updateDisplayList(w,h);
}
]]>
</fx:Script>
<s:Image id="imgA" visible="false" top="0" maintainAspectRatio="true" />
</s:Group>
Any help is greatly appreciated -- I'm also open to an alternate method of resizing the image if it makes more sense.
Thanks in advance