I have a picture of a lovely kitten, and I want to display it in my Flex application without using the old Image halo compoment.
I'll use the BitmapImage spark component which is a spark primitive, which is very interesting because of its 3 available resize modes.
Here is how to display a picture without changing anything (width, height...), and the default resize mode, wich is "NORMAL" :
<?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">
<!-- Default picture display -->
<s:BitmapImage source="@Embed('assets/kitten.png')" />
</s:Application>
Now, as my picture's dimensions are 57 by 100, I'm gonna display it with the dimensions of 161 by 300, three times my picture's orginal dimensions. I'll use the "scale" resizeMode, so my picture will be strectched :
<?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">
<!-- Stretched picture display -->
<s:BitmapImage source="@Embed('assets/kitten.png')" width="161" height="300" resizeMode="scale" />
</s:Application>
There also is a "repeat" mode. With such a mode, instead of stretching my poor kitten, I'll repeat my picture data (but you've probably deduced that by yourself) and fill the whole region :
<?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">
<!-- repeating picture display -->
<s:BitmapImage source="@Embed('assets/kitten.png')" width="161" height="300" resizeMode="repeat" />
</s:Application>
You can have the same result, using the "normal" resize mode and the "repeat" attribute set to true :
<?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">
<!-- repeating picture display -->
<s:BitmapImage source="@Embed('assets/kitten.png')" width="161" height="300" resizeMode="normal" repeat="true" />
</s:Application>