Here's my problem. I have an mx:Image within an mx:DataGrid column. If I do not specifically set the width and height of the image, when the image loads into the grid, only a portion of the image is being displayed.
Recreation Steps:
- Create new Flex Project (Desktop)
- Configure project to use Halo Theme.
Add the following code in their respective locations *Note: Make sure the creationComplete event for the windowedApplication is assigned. Also may need some tweaking for any import statements, etc. Sorry.*
This is a quick example of the issue I'm having. When you launch the program, you will see a portion of the image. When you click Rebind, the full image will occur.
I'm trying to get the full image to be displayed on the first bind, not the second without setting the dimensions in the MXML. I have not been successful in having the full image display via ActionScript without some sort of user interaction to occur.
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
BindData();
}
private function BindData():void
{
var objOrderItem:Object = new Object();
var items:ArrayCollection = new ArrayCollection(new Array(objOrderItem));
dgMain.dataProvider = new ArrayCollection(items.source);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox width="100%">
<mx:Button label="Rebind" click="BindData()" />
<mx:DataGrid id="dgMain" resizableColumns="false" draggableColumns="false"
sortableColumns="false" rowCount="1">
<mx:columns>
<mx:DataGridColumn headerText="Thumb" sortable="false" width="60">
<mx:itemRenderer>
<fx:Component>
<mx:HBox horizontalGap="0" verticalScrollPolicy="off" horizontalScrollPolicy="off" width="100%">
<mx:Image source="https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcTTuc9n_oweh-dv4LUljzh0Lxzn1AvZchODUoSAeGePaDwPqUuw"
width="60" maintainAspectRatio="true" />
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Label text="Text After Grid" />
</mx:VBox>
Thanks in advance!