Reputation: 1442
I am using Flex Builder 3.0 and i want to add image in tile list dynamically then how its possible. Images are stored in Images folder of src. and my array is similar like that.
private var arrImage:Array = [
{source:"Images/1.png",tooltip:"1"},
{source:"Images/2.png",tooltip:"2"},
{source:"Images/3.png",tooltip:"3"},
{source:"Images/4.png",tooltip:"4"},
{source:"Images/5.png",tooltip:"5"},
{source:"Images/6.png",tooltip:"6"},
{source:"Images/7.png",tooltip:"7"},
{source:"Images/8.png",tooltip:"8"},
{source:"Images/9.png",tooltip:"9"},
{source:"Images/10.png",tooltip:"10"}];
my tile list dataprovider is arrImage.
Upvotes: 1
Views: 999
Reputation: 3565
You can use the iconField
property for this.
For example in your case:
<mx:TileList dataProvider="{arrImage}" iconField="source"/>
Read the livedocs for more info on this.
Upvotes: 1
Reputation: 1402
Please Try this Code.....
private var arrImage:Array = [
{source:"Images/1.png",tooltip:"1"},
{source:"Images/2.png",tooltip:"2"},
{source:"Images/3.png",tooltip:"3"},
{source:"Images/4.png",tooltip:"4"},
{source:"Images/5.png",tooltip:"5"},
{source:"Images/6.png",tooltip:"6"},
{source:"Images/7.png",tooltip:"7"},
{source:"Images/8.png",tooltip:"8"},
{source:"Images/9.png",tooltip:"9"},
{source:"Images/10.png",tooltip:"10"}];
<mx:TileList id="tileList" dataProvider="{arrImage}" columnCount="1" columnWidth="100"
useRollOver="false" selectable="false" backgroundAlpha="0" borderStyle="none"
rowHeight="65" verticalScrollPolicy="off" horizontalScrollPolicy="off" >
<mx:itemRenderer>
<mx:Component>
<mx:VBox width="100%" height="100%" horizontalAlign="center" verticalGap="0"
verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
override public function set data(value:Object):void
{
if(value !=null)
{
super.data = value;
if(img !=null)
{
img.source = data.source;
img.toolTip = data.tooltip;
}
}
}
]]>
</mx:Script>
<mx:Image id="img" />
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
Upvotes: 3